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

Locked Element

Anonymous
Not applicable
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?
https://Archicad-talk.Graphisoft.com/viewtopic.php?f=23&t=48644&p=240838&hilit=lock#p24083

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?
3 REPLIES 3
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
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.
Anonymous
Not applicable
Hi!
Does the API_Elem_Head.lockId logic still apply for AC21 & AC22? I am trying to get the locked state of elements in a model that isn't using Teamwork, but lockId stays 0 all the time.
Br,
Lars
Akos Somorjai
Graphisoft
Graphisoft
Hi Lars,

Yes, it applies. An element can also be locked if it is on a locked layer (so check the layer attribute as), not just when it is locked directly.
Alternatively, you can use ACAPI_Element_Filter (elemGuid, APIFilt_IsEditable) if you are checking that an element is editable.

Best, Akos