License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

ACAPI_Element_UnLink issues

Anonymous
Not applicable
After used ACAPI_Element_UnLink to delete all links of an element , the number of the links got by ACAPI_Element_GetLinks is still not zero.
(The links is created and deleted by the same add-on, alos set undo functions )
8 REPLIES 8
Ralph Wessel
Mentor
wcyoot wrote:
After used ACAPI_Element_UnLink to delete all links of an element , the number of the links got by ACAPI_Element_GetLinks is still not zero.
(The links is created and deleted by the same add-on, alos set undo functions )
Are you first calling ACAPI_Element_GetLinks to retrieve a list of linked elements, and then repeatedly calling ACAPI_Element_UnLink to remove each link? Does ACAPI_Element_UnLink return an error? And are you sure the guid_linkFrom and guid_linkTo parameters are in the right order?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
Are you first calling ACAPI_Element_GetLinks to retrieve a list of linked elements, and then repeatedly calling ACAPI_Element_UnLink to remove each link? Does ACAPI_Element_UnLink return an error? And are you sure the guid_linkFrom and guid_linkTo parameters are in the right order?
Yes, I am first calling ACAPI_Element_GetLinks, and then calling ACAPI_Element_UnLink one by one, and sure ACAPI_Element_UnLink returns no error, and sure parameters are in the right order
Ralph Wessel
Mentor
wcyoot wrote:
Yes, I am first calling ACAPI_Element_GetLinks, and then calling ACAPI_Element_UnLink one by one, and sure ACAPI_Element_UnLink returns no error, and sure parameters are in the right order
I'm not sure what else to suggest - this call works for me. Which version of ArchiCAD are you developing for? Can you post some of the essential code that demonstrates this problem?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
I'm not sure what else to suggest - this call works for me. Which version of ArchiCAD are you developing for? Can you post some of the essential code that demonstrates this problem?
AC13.

err = ACAPI_Element_Get (&element);
API_Guid		linkFrom = element.header.guid;
API_Guid**		linkToList = NULL;
err = ACAPI_Element_GetLinks (linkFrom, &linkToList, &nLinks);	
   for (GSIndex index = 0; index < nLinks; index++) {
   err = ACAPI_Element_Unlink (linkFrom, (*linkToList)[index]);
      }
BMKillHandle ((GSHandle *) &linkToList);
Int32 nLinksTemp = 0;
err = ACAPI_Element_GetLinks(linkFrom, NULL, &nLinksTemp);
// There nLinksTemp is not zero
Ralph Wessel
Mentor
wcyoot wrote:
AC13.

err = ACAPI_Element_Get (&element);
API_Guid		linkFrom = element.header.guid;
API_Guid**		linkToList = NULL;
err = ACAPI_Element_GetLinks (linkFrom, &linkToList, &nLinks);	
   for (GSIndex index = 0; index < nLinks; index++) {
   err = ACAPI_Element_Unlink (linkFrom, (*linkToList)[index]);
      }
BMKillHandle ((GSHandle *) &linkToList);
Int32 nLinksTemp = 0;
err = ACAPI_Element_GetLinks(linkFrom, NULL, &nLinksTemp);
// There nLinksTemp is not zero
That looks OK to me. Are you doing this within an Undo session, i.e. using ACAPI_OpenUndoableSession?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
That looks OK to me. Are you doing this within an Undo session, i.e. using ACAPI_OpenUndoableSession?
Yes, Of course. I am sure.
Ralph Wessel
Mentor
wcyoot wrote:
Ralph wrote:
That looks OK to me. Are you doing this within an Undo session, i.e. using ACAPI_OpenUndoableSession?
Yes, Of course. I am sure.
These functions work for me, so I don't know what else to suggest. I recommend cutting the add-on functionality down to the bare minimum required to test this code. Then you can be sure that the problem isn't caused by some earlier corruption.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
These functions work for me, so I don't know what else to suggest. I recommend cutting the add-on functionality down to the bare minimum required to test this code. Then you can be sure that the problem isn't caused by some earlier corruption.
In my test, there is nothing else to do.

Maybe it is a bug.