The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

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

Moderators: LaszloNagy, ejrolon, Barry Kelly, Karl Ottenstein, gkmethy, 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 allModelerAPI::Element element; ModelerAPI::BaseElemId baseId; element.GetBaseElemId(&baseId);
Code: Select allModelerAPI::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?
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 allvoid ElementExporter::GetBaseElemId (const ModelerAPI::Element& element, ModelerAPI::BaseElemId* baseElemId) { GS::NonInterruptibleProcessControl processControl; element.GetBaseElemId (baseElemId, processControl, ModelerAPI::Element::EdgeColorInBaseElemId::NotIncluded, ModelerAPI::Element::PolygonAndFaceTextureMappingInBaseElemId::NotIncluded, ModelerAPI::Element::BodyTextureMappingInBaseElemId::NotIncluded, ModelerAPI::Element::EliminationInfoInBaseElemId::NotIncluded); }
Regards, Akos