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

I have a problem when I release 'ExternalGlobalId'

YONGWOO KIM
Participant

I have some problem to get 'ExternalGlobalId' and 'GlobalId' in ArchiCAD28.

 

I want to get 'ExternalGlobalId', if there 'ExternalGlobalId' is exist.

 

And, if 'ExternalGlobalId' is not exist, I want to get 'GlobalId'.

 

An error occurs when exiting the for loop.

Occurs only when 'ExternalGlobalId' is not present.

 

In 'Microsoft Visual Studio\2019\Professional\VC\ToolsMSVC\14.29.30133\include\xmemory'.

0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF

ExternalGlobalId_stack.png

 

This is my code.

 

for (int i = 0; i < selList.GetSize(); i++)
{
	UniString ifcType = L"", ifcIdStr = L"";

	API_Elem_Head elemHead;
	elemHead.guid = selList[i].GetGuid();
	ACAPI_Element_GetHeader(&elemHead);
	auto objectID = IFCAPI::GetObjectAccessor().CreateElementObjectID(elemHead);
	auto ifcTypeResult = IFCAPI::GetObjectAccessor().GetIFCType(objectID.Unwrap());
	if (ifcTypeResult.IsOk())
		ifcType = ifcTypeResult.Unwrap();

	auto externalGlobalId(IFCAPI::GetObjectAccessor().GetExternalGlobalId(objectID.Unwrap()));
	if (externalGlobalId.IsOk())
	{
		ifcIdStr = externalGlobalId.Unwrap();
	}
	else
	{
		auto globalId = IFCAPI::GetObjectAccessor().GetGlobalId(objectID.Unwrap());
		if (globalId.IsOk())
			ifcIdStr = globalId.Unwrap();
	}
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Adam Toth
Graphisoft
Graphisoft

Hi

 

Does this occur with a Debug, or Release/RelWithDebInfo Add-On build?
I've seen stg. similar, when using a Debug AddOn with an Archicad release, while it worked with the Rel-Rel combination.

Ádám Tóth
Software Engineer, Graphisoft

View solution in original post

3 REPLIES 3
Solution
Adam Toth
Graphisoft
Graphisoft

Hi

 

Does this occur with a Debug, or Release/RelWithDebInfo Add-On build?
I've seen stg. similar, when using a Debug AddOn with an Archicad release, while it worked with the Rel-Rel combination.

Ádám Tóth
Software Engineer, Graphisoft

It solved with Release.

However, is there any plan to fix it in the future?

I had a similar issue a while ago. You can change your Debug build setup a little bit to get rid of the issue in Debug builds.
Graphisoft now discourages using ACAP_STATD.lib. Instead you should always link to ACAP_STAT.lib also in Debug build and set the ITERATOR_DEBUG_LEVEL=0. After changing these two things, I didn't have any issues anymore in debug mode and attaching a debugger works as well still.

More details here: https://community.graphisoft.com/t5/Archicad-C-API/Crash-for-GetOrganizationIds-in-DEBUG-builds-link...