Archicad C++ API
About Archicad add-on development using the C++ API.

drwIndex, send to front/back

Anonymous
Not applicable
Hello,

I want to programmatically send elements to front/back and am finding strange things with element.header.drwIndex.

According to the docs:
drwIndex
The index of the element in drawing order. It is important for bring to front/send to back type operations. Elements with higher drwIndex are drawn last.

Is there some trick to using this? Or some bug in version 7 of ArchiCAD?
I've made a simple SendToFront function and in my tests if I set this value to anything higher than 14 (decimal) it gets set back to 1.

Any insight would be much appreciated.

Thanks,
Adam
5 REPLIES 5
Anonymous
Not applicable
After a bit of playing I got around this problem like this:

while(true)
{
tempElement = element
tempElement.header.drwIndex++;
ACAPI_Element_Create(tempElement)
if(tempElement.header.drwIndex <= element.header.drwIndex)
{
ACAPI_Delete... tempElement
break;
}
ACAPI_Delete... element
element = tempElement
}

This seems a bit dodgy but it works - I'm still wondering if there is a better way to do this???
stefan
Expert
I remember from the manuals that there are only about 15 depth layers in total. That might explain why it suddenly jumps forward at 14 or so...

Each element gets a default level, but for the elements you need it you can override it (with limitations, such as the total amount of available levels).
--- stefan boeykens --- bim-expert-architect-engineer-musician ---
Archicad27/Revit2023/Rhino8/Unity/Solibri/Zoom
MBP2023:14"M2MAX/Sonoma+Win11
Archicad-user since 1998
my Archicad Book
Oleg
Expert
I do not know exactly is it a bug of 7 version, but I remember, that when I used it early and I needed set a some fixed drwIndex, I used a loop too using APITool_BringForward and APITool_SendBackward functions commands of ACAPI_Element_Tool function. If you need just send from/back you can use the function.

PS: And I think, that the drawing index is limited to the 1-14 range.
Ralph Wessel
Mentor
adambutler wrote:
I want to programmatically send elements to front/back and am finding strange things with element.header.drwIndex.

According to the docs:
drwIndex
The index of the element in drawing order. It is important for bring to front/send to back type operations. Elements with higher drwIndex are drawn last.
It appears that this value is read-only in the element header. Any changes you make are ignored. The only way to change it is through ACAPI_Element_Tool with APITool_BringForward, APITool_SendBackward, APITool_SendToBack, or APITool_ResetOrder.
Ralph Wessel BArch
Anonymous
Not applicable
Thanks, I should have done more searching through the docs. APITool_SendToFront is working nicely.