Create a Cadwork material group using c++ API
-
I am trying to create a new material group using the C++ Cadwork API.
Using the UI, I would use the "new material group" button :

Is that function currently available in the API ?
The
ICwAPI3DMaterialControllerallows me togetGrouporsetGroupbut notcreateGroup.Thanks a lot,
Sylvain -
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"); } }