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

changing visibility of an element

Anonymous
Not applicable
Hello,

I've updated my code to work with the ArchiCAD 9 API_StoryVisibility structure. Its working fine for slabs, but not for objects.

I basicly force my library parts to be set to the story settings I require. This is an integral part of my apx and has always worked fine using showAbove, showBelow in version 7.

Here code that should set an object to be 'show above and below', but doesn't work for me. I can't understand why:

err = ACAPI_Element_Get(&element);
if(err == noErr)
{
   element.object.visibility.showRelAbove = 1;
   element.object.visibility.showRelAbove = 1;
   ACAPI_ELEMENT_MASK_SET(mask, API_ObjectType, visibility);
   err = ACAPI_Element_Change(&element, mask, nil, 0, true);
   if(err == noErr)
   {
      err = ACAPI_Element_Get(&element);
      if(err == noErr)
      {
         // The function gets here, but showRelAbove & showRelAbove are set back to zero
      }
   }
}

   }
}
As a test I tried this (which also doesn't work):

err = ACAPI_Element_Get(&element);
if(err == noErr)
{
   element.object.visibility.showRelAbove = 1;
   element.object.visibility.showRelAbove = 1;
   ACAPI_ELEMENT_MASK_SETFULL(mask);
   err = ACAPI_Element_Change(&element, mask, nil, 0, true);
   if(err == APIERR_BADPARS)
   {
         // The function gets here and I can't see what would casue this
   }
}
The only way I can think to do it is to deletes and recreate the element. It seems vey ineffecient. If I am forced to use this method I will have to do lots of extra work to recreate links to this element from dimensions, etc.

Has anyone had this working?
Any idea what I'm doing wrong?
Are there other parts of elements that I won't be able to edit now in version 9?

Thanks,
Adam
2 REPLIES 2
Ralph Wessel
Mentor
adambutler wrote:
I've updated my code to work with the ArchiCAD 9 API_StoryVisibility structure. Its working fine for slabs, but not for objects.

   err = ACAPI_Element_Change(&element, mask, nil, 0, true);
   if(err == APIERR_BADPARS)
   {
         // The function gets here and I can't see what would casue this
   }
The error APIERR_BADPARS can be returned if you haven't preceeded ACAPI_Element_Change with ACAPI_OpenUndoableSession. Could this be the problem?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Hello,

This is done in the new element database handler which the docs say 'cannot open undoable sessions because they are called from an already opened undo step'.

I tried putting this code behind a menu item with the openundo call and still get the same problem.

Thanks,
Adam