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

Use of ACAPI_element_UnIdToGuid

Anonymous
Not applicable
Hi,

I have a drawing in ArchiCAD 9.0, in which one element stores the ‘unId’ of other element as the parameter ‘parent_unId’. (That is the way we relate each other elements parent child relation ship).
In this scenario my parent element is door element and child is door extra element.

Now we are opening this drawing with ArchiCAD 13.0 I need to convert ‘parent_unid’ to API_Guid.
I am trying to use following function when I receive APINotify_ConvertUnId notification.

OSErr DOConvertUnId()
{
	API_Element element;
	API_ElementMemo memo;
	API_DatabaseInfo dbInfo;
	API_Guid parentGuid = APINULLGuid;
	Int32 ii, num;

	SetDB(FLOORPLAN);//our function
	BNZeroMemory(&dbInfo, sizeof(API_DatabaseInfo));
	if(ACAPI_Database(APIDb_GetCurrentDatabaseID, &dbInfo, NULL) == NoError)
	{
		ACAPI_Element_GetNum(API_ObjectID, &num);
		for(ii = 1; ii <= num; ii++)
		{
			if(ACAPI_Element_Filter_Index(API_ObjectID, ii, APIFilt_IsEditable))
			{
				memset(&element, 0, sizeof(API_Element);
				element.header.typeID = API_ObjectID;
				element.header.index =ii;
				if(ACAPI_Element_Get(&element) == NoError && element.object.libInd == utLibIndStore->DoorExtraInd)
				{
					memset(&memo, 0, sizeof(API_elementMemo);
					if(ACAPI_Element_GetMemo(element.header.guid, &memo) == NoError)
					{
						parentGuid = ACAPI_element_UnIdToGuid(dbInfo.databaseUnId, (GS::Uint32) GetParamValue(memo.parms, “parent_unid”));
						if(parentGuid != APINULLGuid)
						{
							char guidStr[64];
							APIGuid2GSGuid(parentGuid).ConvertToString(guidStr);
							GiveMsg(guidStr);
						}
					}
				}
			}
		}
	}
}
This function giving the guid message but the guid it displays is of one of the wall (not the wall contained my door), not door.
I am thinking problem in this function ACAPI_Database(APIDb_GetCurrentDatabaseID, &dbInfo, NULL);

Can any one please explain me what are the databases I have to look to convert unId to guid and how to use ACAPI_element_UnIdToGuid() function?

Ranga
3 REPLIES 3
Hoa Tu
Newcomer
Hi,

I haven't had any experience with this function yet, but I am guessing you should use API_DoorID instead of API_ObjectID.

Regards,
Hoa
Anonymous
Not applicable
Hi,

Thanking you for replay.

My child element (doorExtra) is an object, which stores the unId of door element. So, first I am getting my doorExtra then I am getting “parent_unid” and try to convert this into guid using this function.
parentGuid = ACAPI_element_UnIdToGuid(dbInfo.databaseUnId, (GS::Uint32) GetParamValue(memo.parms, "parent_unid"));
But I am getting guid of wall instead of door. ( if I open my drawing with ArchiCAD 9.0 “parent_unid” stored in the doorExtra object is unId of one of the door.
Anonymous
Not applicable
Please some one help me in this issue.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!