2023-01-15 11:50 PM - last edited on 2024-09-24 10:29 AM by Doreena Deng
This is a random question I've been ruminating for a while. Can we generate a working xml object via python?
The question came about because I was wondering if I could partially automate object making. At the moment, we have a workflow where people would create an entry to drofus to reflect the object they need. From that entry, I will create the object. Funny thing is the object will end up as a box, which I will update eventually when they actually give me spec for the object.
The thing that I have been ruminating is that I could CRUD drofus with httpx or request and get the newly created data. I also know python standard library include xml parsing. So my theory is since all object share a similar xml structure and since the placeholder object is just a box, I can theoretically create a simple template xml to generate an object.
The bit that I'm not entirely sure about is the unique GUIDs that archicad needs for all objects. Technically I can generate GUIDs with python but I don't know how objects gets registered into archicad.
Solved! Go to Solution.
2023-01-16 01:43 AM
Hi Jack,
Totally possible.
I have messed around with similar stuff in the past. I was using the lxml python package to create and modify the xml nodes from a decompiled gsm.
I think you idea of using a template xml object, and then modify the parameters of that xml file and assign it a new name and guid sounds fairly straightforward.
With regard to GUID's as long as you have a unique GUID added to your object this is what Archicad uses to register the object. As long as any modifications to that object do not change the GUID, archicad will register it was this object. (if you change GUID you have to use migration scripts to get it to recognise it as the same object).
I was using the following the create the GUID
import uuid
uuid.uuid4()
and inserting it into this xml node attribute:
Hope that helps.
2023-01-16 01:43 AM
Hi Jack,
Totally possible.
I have messed around with similar stuff in the past. I was using the lxml python package to create and modify the xml nodes from a decompiled gsm.
I think you idea of using a template xml object, and then modify the parameters of that xml file and assign it a new name and guid sounds fairly straightforward.
With regard to GUID's as long as you have a unique GUID added to your object this is what Archicad uses to register the object. As long as any modifications to that object do not change the GUID, archicad will register it was this object. (if you change GUID you have to use migration scripts to get it to recognise it as the same object).
I was using the following the create the GUID
import uuid
uuid.uuid4()
and inserting it into this xml node attribute:
Hope that helps.
2023-01-16 01:58 AM
oh right! I didn't know about UUID. That is a great suggestion.
I was originally hesitant because I thought there was an internal database in archicad where an object registers first before it gets it's unique guid. Rather than the object has a unique guid that archicad just tracks.
Thanks this is useful!
2023-01-16 01:02 PM
Tibor Lorántfy's add-on will prove useful as well, I think.
Then you can trigger a library reload after you have generated your dummy objects.
2023-01-16 11:10 PM - edited 2023-01-16 11:10 PM
Does the reload library also reload BIMcloud library? Because that would make my laziness happy.
I've been looking for something like this for a while. Thanks!
2023-01-17 01:38 AM
That addon triggers that same as clicking 'Reload & Apply' in the library manager.
If it is reading a linked folder and you modify a gsm in that folder from your python script it will show the latest version of the object.
However, it can't upload new files/folders/lcfs to a BIMCloud library unfortunately.
Being able to trigger the functions of 'Manage BIMCloud Libraries' from python would be amazing though! One can only dream.
2023-01-17 02:13 AM
damn... That would be so useful