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

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

firmstudio
Participant

zone_numbering.py [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 zone_numbering.py 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!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

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?

 

 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

View solution in original post

3 REPLIES 3
poco2013
Mentor

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. 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Solution

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?

 

 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
firmstudio
Participant

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.