Retrieve and update the surface color override
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-11-10
12:18 PM
- last edited on
‎2024-09-17
01:20 PM
by
Doreena Deng
Hello, could you please help to advise what API I could use to retrieve and update the surface colour override for an element?
 
Solved! Go to Solution.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-11-14 12:36 PM
This is an element-specific parameter so the way to change the override is dependent on the element type. Let's say you have a guid for an element (for example by enumerating selected elements) and the index of the new Surface (called Material on the API). This code will do the trick for Walls and GDL objects. The other elements work in a very similar way.
API_Element element = {};
element.header.guid = elementGuid;
ACAPI_Element_Get (&element);
API_AttributeIndex newMaterialIndex = ACAPI_CreateAttributeIndex (15);
API_Element mask = {};
ACAPI_ELEMENT_MASK_CLEAR (mask);
switch (element.header.type.typeID) {
case API_WallID:
element.wall.refMat = newMaterialIndex;
element.wall.oppMat = newMaterialIndex;
element.wall.sidMat = newMaterialIndex;
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, refMat);
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, oppMat);
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, sidMat);
break;
case API_ObjectID:
element.object.mat = newMaterialIndex;
element.object.useObjMaterials = false;
ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, mat);
ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, useObjMaterials);
break;
}
ACAPI_Element_Change (&element, &mask, nullptr, 0, true);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-11-14 12:36 PM
This is an element-specific parameter so the way to change the override is dependent on the element type. Let's say you have a guid for an element (for example by enumerating selected elements) and the index of the new Surface (called Material on the API). This code will do the trick for Walls and GDL objects. The other elements work in a very similar way.
API_Element element = {};
element.header.guid = elementGuid;
ACAPI_Element_Get (&element);
API_AttributeIndex newMaterialIndex = ACAPI_CreateAttributeIndex (15);
API_Element mask = {};
ACAPI_ELEMENT_MASK_CLEAR (mask);
switch (element.header.type.typeID) {
case API_WallID:
element.wall.refMat = newMaterialIndex;
element.wall.oppMat = newMaterialIndex;
element.wall.sidMat = newMaterialIndex;
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, refMat);
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, oppMat);
ACAPI_ELEMENT_MASK_SET (mask, API_WallType, sidMat);
break;
case API_ObjectID:
element.object.mat = newMaterialIndex;
element.object.useObjMaterials = false;
ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, mat);
ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, useObjMaterials);
break;
}
ACAPI_Element_Change (&element, &mask, nullptr, 0, true);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2023-11-14 04:49 PM
Viktor, you have provided an accurate solution, thank you so much!