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

Problem using ACAPI_3D_GetComponent

Anonymous
Not applicable
There is a problem using ACAPI_3D_GetComponent.

I am updating from Archicad22 to Archicad24 and it returns an error code of APIERR_DELETED.

It returns NoError when checked with the same code in Archicad22.

I checked that ACAPI_Element_Get3DInfo returns NoError, so it seems that the element exists in the 3D database.

And I can see the element in Archicad 3D view.

long Get3DInfo (const API_Guid& guid) {
	DBASSERT (APINULLGuid != guid);
	m_Guid = guid;
	BNZeroMemory (&m_info3D, sizeof (API_ElemInfo3D));

	API_Elem_Head elemHead;
	BNZeroMemory (&elemHead, sizeof (API_Elem_Head));
	elemHead.guid = m_Guid;

	ACAPI_Element_GetHeader (&elemHead);
	m_err = ACAPI_Element_Get3DInfo (elemHead, &m_info3D);

	if (m_err == APIERR_BADID)
		return 0;
	if (m_err == APIERR_GENERAL)
		return 0;
	if (m_err != NoError)
	{
		ErrorBeep ("Error in ACAPI_Element_Get3DInfo", m_err);
		return 0;
	}

	m_nBody = m_info3D.lbody - m_info3D.fbody + 1;

	if (m_nBody > 0) GetBody (m_info3D.fbody);

	return m_nBody;
}

bool GetBody (long bodyIndex)
{
	DBASSERT (APINULLGuid != m_Guid);
	DBASSERT (bodyIndex > 0);
	DBASSERT (bodyIndex >= m_info3D.fbody && bodyIndex <= m_info3D.lbody);

	BNZeroMemory (&m_component, sizeof (API_Component3D));
	m_component.header.typeID = API_BodyID;
	m_component.header.index  = bodyIndex;
	m_err = ACAPI_3D_GetComponent (&m_component);  // ACAPI_3D_GetComponent return APIERR_DELETED in Archicad24

	if (m_err == APIERR_DELETED)
		m_err = NoError;

	if (m_err != NoError)
	{
		ErrorBeep ("Error in ACAPI_Element_Get3DInfo", m_err);
		return false;
	}

	return true;
}
1 ACCEPTED SOLUTION
2 REPLIES 2

Solution
leilei
Enthusiast
Hi,Maybe the element is column、beam.When you get the guids of beams and columns.You should traverse the sub elements in memo.columnSegments or memo.beamSegments.

for (int i = 0; i < BMpGetSize((GSPtr)(memo.columnSegments)) / sizeof(API_ColumnSegmentType); i++)
{
Get3DInfo(memo.columnSegments.head.guid);
}

Anonymous
Not applicable
leilei wrote:
Hi,Maybe the element is column、beam.When you get the guids of beams and columns.You should traverse the sub elements in memo.columnSegments or memo.beamSegments.

for (int i = 0; i < BMpGetSize((GSPtr)(memo.columnSegments)) / sizeof(API_ColumnSegmentType); i++)
{
Get3DInfo(memo.columnSegments.head.guid);
}
Thank you. It works!

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!