The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy, rmasaki

User avatar
By kzaremba
I'm investigating the locking system. As far as I know, there are 4 different ways to make elements unable to modify in AC:
- Edit/Lock
- Layer Lock
- Teamwork Lock
- Being a member of hotlink

I found a detailed example of Teamwork lock here but what about nonTeamwork files?

In API_Element there is lockId which should work as bool in offline mode. I tried both with locking and layers but it's always 0. Is there any special function for filling this property or its wrong one?

If locked doesn't indicate layer lock status should go with Layer Index and check its visibility?
User avatar
By Tibor Lorántfy
Yes, you are right those are the 4 different ways, but the Edit/Lock does not count when the current project is a Teamwork project, and the "Teamwork Lock" does not count when it's a normal (not Teamwork) project. The ACAPI_TeamworkControl_HasConnection function tells whether the currently opened project is a Teamwork project.

1. Edit/Lock
- if the element is locked then the value of elem.header.lockId is 1
- the elem.header.lockId is a read-only field, so to lock/unlock an element use ACAPI_Element_Tool with APITool_Lock/APITool_Unlock parameters.
2. Layer Lock
- you can get the index of the element's layer from elem.header.layer and you have to retrieve the layer attribute using ACAPI_Attribute_Get to get the flags of the layer. If the flags of the layer contains APILay_Locked then the layer is locked, so the element is on a locked layer.
- you must modify the element's layer using ACAPI_Attribute_Modify to lock the layer.
3. Teamwork Lock
- your link leads to a good example, so I don't go into the details here.
4. Hotlinked element
- if the element is a member of a hotlink then the elem.header.hotlinkGuid is not APINULLGuid.