We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

Possible to add property definitions on project open/new?

cfranklin
Newcomer
Hi again,

Curious as to if I can create a few new property definitions from a project event, so all projects with the add-on will have these new properties to have their values set later on elements.

It seems the only hangup is that
ACAPI_Property_CreatePropertyDefinition()
needs undoable scope, but calling that command via CallUndoableCommand from any of the project events (ACAPI_Notify_CatchProjectEvent) causes a crash.

I assume this is explained here in the docs of CallUndoableCommand :
Add-ons may not call this function from their element database event handler callback, because those notifications are sent from within an existing database transaction."


Does this mean that its impossible to create properties from callbacks of project events? I have no issues creating properties from a CatchNewElement callback...

Thanks
3 REPLIES 3
cfranklin
Newcomer
One other thing... Its strange that this causes a crash but creating a property group does not. I can successfully create a property group from a project open event just fine.
Ralph Wessel
Mentor
I'm not certain whether this operation is supported during that notification, but there is an alternative solution. Take a look at the documentation for ACAPI_Command_CallFromEventLoop. Use this function to instruct ARCHICAD to call your add-on at a point when it is suitable to handle functions that might otherwise be context-sensitive. There is example code with the documentation.
Ralph Wessel BArch
Software Engineer Speckle Systems
cfranklin
Newcomer
Thanks! Really appreciate the help, seems I miss things in the docs all the time...