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

acc.GetElementsByType('Zone') only the visible zones

Participant [script from Archicad website]

Zone NumberingGenerates unique ordered zone numbers. Sets the “zone number” built-in property value for all zones in the project. The script implements a zigzag ordering.


I want to edit the the and change the way the example provided by Graphisoft works.

Is it possible to filter out the visible zones in the aray of selected zones. So that only the items visible get a new zone number?


Thanks in advance!


You did not mention by what criteria you define visibility? Is it a selection set, visible layer or story etc. In any case, the short answer is "yes".


The procedure would be to simply return all Zone Id's, as in the example, then apply a filter to create a subset then, with that subset, apply with the rest of the code as normal.


Assuming you want to filter on Layer visibility - The filter steps would be -- return the layer name for zone element, for each zone name ,iterate though all available Layers to determine if that layer is visible. If so, mark the element Id as true. Unfortunately, there is no function to select a layer by name, this the need to iterate - this makes the script relatively slow.


Other options would be handled the same, abet with a much simpler filter. However, if you want to filter on a user selection set, the Python API does not have that function ( at this time). However, on my GiyHub site I have created a AddOn to provide that ability - Archicad_Python_Training -- Data_Access.apx. Either way the above is possible. 


Windows 11 - Visual Studio 2022; ArchiCAD 27

Attached is a revised zone numbering example Python script which filters out zones on invisible layers as described above. Comment if you have any questions? Note the slow performance?




Windows 11 - Visual Studio 2022; ArchiCAD 27

Thank you very much! This is really helpful. The script is indeed a bit slower but it's always faster then doing it by hand. Thank you for your effort.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!