Skip to content

Scripting / API

Tausche dich über die Cadwork-API und Skripterstellung aus. Stelle Fragen, teile Codebeispiele und entdecke neue Automatisierungsmöglichkeiten.


Discuss the Cadwork API and scripting. Ask questions, share code examples, and explore new automation possibilities.

1 Topics 3 Posts
  • Create a Cadwork material group using c++ API

    3
    +0
    0 Votes
    3 Posts
    203 Views
    S
    Here is a snippet working for me // convert string to wstring std::wstring ToWideString(std::string narrowString) { return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(narrowString); } void CreateMaterial(CwAPI3D::MaterialController* mc) { // get the string value of the material auto newMaterialNameWS = ToWideString(Value); auto newMaterialNameCS = newMaterialNameWS.c_str(); // check if the material exists auto material_id = mc->getMaterialID(newMaterialNameCS); if (material_id == 0) { // if the material does not exist, create it material_id = mc->createMaterial(newMaterialNameCS);; // set the material group to switchboard materials mc->setGroup(material_id, L"Switchboard_Materials"); } }