Archicad Python API
About automating tasks in Archicad using the Python API.

Change the Layer of Elements -

smathiebe
Contributor

Hi All,

i wrote a script to change the layer-values of elements in the model.

But i got the result

 

FailedExecutionResult {'success': False, 'error': {'code': 6800, 'message': 'Value of property definition is read-only (property definition guid: "812CD483-40FB-4E75-966F-E76C3E68B9F7")'}}

for every element.

 

What is wrong?

Thanks in advance

 
elements = acc.GetAllElements()
# get GUID for ModelView_LayerName
propertyId = acu.GetBuiltInPropertyId('ModelView_LayerName')

# get list with Element-Layers
actValues = acc.GetPropertyValuesOfElements(elements,[propertyId])
#create list with new values
TestValue = "10 WAND - innen.Wand"
NewPropertyValues = []
for i in range(len(elements)) :
    NewPropertyValues.append(act.ElementPropertyValue(elements[i].elementId,propertyId,act.NormalStringPropertyValue(TestValue)))

# sent changes to Archicad
result = acc.SetPropertyValuesOfElements(NewPropertyValues)
print(result)

 

AC25-28, Win10
2 REPLIES 2
JT1986
Booster

Hi smathiebe,

 

As far as I know, currently you can only check the layer name (property value) of an element and use it as one condition inside a script to delimit a group of elements, for example.


But moving an element completely to another layer is unfortunately not possible with the python API. This is why the script returns a "Value of property definition is read-only" -error.

 

-JT

poco2013
Mentor

FYI: a layer is a fundamental built in property, created by Graphisoft, which controls a attribute of the plan. It is hard coded by Archicad which is why it is read only (at least at this time?). However, you can change the layer through the API function: ACAPI_Element_Change( ). You can also reach and program this function from a Python script by using the Python function ExecuteAddOnCommand and passing the appropriate parameters. But this would also involve creating and installing the relative specific AddOn. The developer's Kit has examples for both the interface and Element Change.

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27