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

Get the Type ID and Variation ID from API_LibPart

gehairing
Participant
Hello the forum

I download library parts and insert them in Archicad projects.
To do the job correctly i need to know what is exactly the library part.
(a stair, a window, a door, a wall...)

For the moment i have this info in xml side-car files so i know exactly the type of the library part. I can fill in the "element.header.typeID" and "element.header.variationID" based on the data i have in my XML side-car.

But...

For some of my library parts i don't have the XML data so i don't know the type of the libpart.

How can i find "element.header.typeID" and "element.header.variationID" from a API_LibPart ?

I have the "API_LibTypeID" but this is not enough. By example, i can't know that a libpart is a "stair" by example.
5 REPLIES 5
Ralph Wessel
Mentor
gehairing wrote:
i need to know what is exactly the library part.
(a stair, a window, a door, a wall...). [...] How can i find "element.header.typeID" and "element.header.variationID" from a API_LibPart ? I have the "API_LibTypeID" but this is not enough. By example, i can't know that a libpart is a "stair" by example.
You could deduce this from the library part subtype, API_LibPart::ownUnID. Its ancestry would determine what tool/type it's related to.
Ralph Wessel BArch
gehairing
Participant
Thank you for the answer...but i don't understand what you mean.
Do you mean the ownUnID can give me an element from wich i can extract typeID and VariationID ?

I have tried playing around with something like this :
GS::UniString s = libPart.ownUnID;
	GS::Guid gs_guid(s);
	API_Element  element;
	BNZeroMemory (&element, sizeof (API_Element));
	element.header.guid  = GSGuid2APIGuid (gs_guid);
	GSErrCode err = ACAPI_Element_Get(&element);
	if(err == NoError)
	{
		typeID = element.header.typeID;
		variationID = element.header.variationID;
	}
But because i don't really know what it means i can't say why it doesn't work
Ralph Wessel
Mentor
gehairing wrote:
Do you mean the ownUnID can give me an element from wich i can extract typeID and VariationID ?
Library parts are organised in a hierarchical structure, so the 'subtype' of an object determines its parent and therefore its 'type'. If you refer to the attached image, you can see the ARCHICAD Subtype selection dialog with the Stairmaker subtype selected. This would make the object a type of 'Stair' (and also a type of 'Model Element').

You can use the subtype of your library parts to determine if they are descended from specific types, and therefore determine which tool they are associated with.
Ralph Wessel BArch
gehairing
Participant
Thank you Ralph.

Sorry, I don't understand how can i access the subType you talk about ?
Ralph Wessel
Mentor
gehairing wrote:
Sorry, I don't understand how can i access the subType you talk about ?
For background information, look at the Library Part Subtypes documentation with the API. There is a link to it from the API_LibPart page. The subtype identifier for a library part is API_LibPart::ownUnID. You will find functions like APIAny_CheckLibPartSubtypeOfbyMainID and APIAny_CheckLibPartSubtypeOfID to be useful.
Ralph Wessel BArch