The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy

By Arc
Hello. I want to ask if there is any way to check if an element/body is an instance of another in Archicad 22's API. I have tried many things such as checking Guids of the various components, comparing indexes of polygons. But after much testing, it is extremely difficult to verify whether or not an element still remains an instance of element.

In Archicad 21, I used to be able to extract the ModelerAPI::BaseElem from the ModellerAPI::Element and check the hash value to compare between other base elements to determine whether they share the same geometry. Archicad 22 seems to have deprecated this class and I no longer have access to it.

I much appreciate any advice and apologise if I utilise terms not native to Archicad.
User avatar
By Akos Somorjai

AC 22 introduced the ModelerAPI::BaseElemId to solve that kind of issue. This can be used to compare instances of elements, it has operator== defined. It can also serve as a hashable key.

Call elem.GetBaseElemId() to access it.

Regards, Akos
By Arc
Thank you for the reply.

I tried to use it but I encountered a problem where I cannot seem to obtain the BaseElemId without at the same time requiring to extract a lot of other types of Ids as well.
Code: Select all
ModelerAPI::Element element;
ModelerAPI::BaseElemId baseId;
Code: Select all
ModelerAPI::Element element;
ModelerAPI::BaseElemId baseId = element.GetBaseElemId();
Neither of the above seem to be able to just give me the BaseElemId. The first one requires me to also add a bunch of parameters that I don't know how to initialise and does not seem to accept nullpointers. The second one cannot work because it is a void function and thus does not return anything. Is there an example I can refer to as reference with regards to using this function?
Arc wrote:
Thu Nov 22, 2018 11:08 am
Thank you for the reply.

Is there an example I can refer to as reference with regards to using this function?
Here it is:
Code: Select all
void ElementExporter::GetBaseElemId (const ModelerAPI::Element& element, ModelerAPI::BaseElemId* baseElemId)
	GS::NonInterruptibleProcessControl processControl;
	element.GetBaseElemId (baseElemId,
Regards, Akos