cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

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

Help regarding python script -> change ID of elements

Petar
Booster

Dear community, 

I have (I imagine) a very simple issue that I am trying to resolve in python. I am trying to select for example all walls which have composite structure type, and then change id of each wall to the name of the composite which is assigned to that wall. 

I managed to select 

walls = acc.GetElementsByType('Wall')
but I can not figure out how to access attributes of the wall(such as id, or structure type) 
Please bear in mind that I am quite a beginner in terms of Archicad python API.
Thank you in advance,
Regards,
Petar
 

 

5 REPLIES 5
poco2013
Mentor

Changing the "element ID" is fairly straight forward in Python. It involves getting the property ID, the Guid of the element to be changed and then using:

acc.GetBuiltInPropertyId('General_ElementId) to get the property identifiers,

acc.SetPropertyValuesOfElements(Array) to reset the value of the ID's.

 

All of this is explained in the python API documentation referenced on their pypi site:

PyPi Site 

 

Unfortunately, the Python API does not presently have access to the Wall element Composite Names, so using that to Alter the ID's is not possible now with just Python.

However I have extended Python's access to allow this through a AddOn that uses the Execute Command Handler Function . The AddOn permits access to the AutoText properties of the element, which in this case, would be "Composite Structure". Relatively straightforward and just adds a additional step or so to a short Python Script. You would also have to add the logic to select only composite Walls

I Demo the procedure(s) in a YouTube video(s) if your interested.

YouTube Utility Video 

I believe the procedure is self explanatory, but if you have further questions, i can make an additional specific video.

 

However, i am guessing that it might be easier for you to just use the interactive schedules and perhaps Excel, all of which is explained in the Archicad help Documentation.

 

If you have any specific questions, just comment below. Good Luck.

 

 

Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
Ady84a
Booster

python has access to the custom properties. so you can create a custom property for walls and select any type of data you want like structure type. then use this custom property in your python script and change the ID. 

Ady84a, thank you for your suggestion. This seems to be a usable workaround. 

 

Thank you very much for the time and effort to explain the process. Also, after little reading and going through your youtube channel, it does seems to me that your addon expands the capability of native python significantly (bears the question of why it was not yet implemented by graphisoft). 

I will give it a go, and post results here, maybe it will be useful to other users as well. I would like to see some beginner-oriented tutorials regarding python and Archicad, just to demonstrate what is possible, not necessarily going deep into python as a programming language. 



 

Would it be possible to access composites via python and change their names for example? This could be useful in terms of sorting and name coding composites inside a file (which I personally leave to do at the end of the project). For example, one could sort composites based on the total thickness or something like that. 

Hi Gerry, any chance you could make your video public? I am trying to do something similar - overwrite all Element IDs with a value of another property. I guess that video would be very helpful. 

Thanks!