GDL
About building parametric objects with GDL.
SOLVED!

generating xml object via python

Jack D
Booster

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
scottjm
Advisor

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:

scottjm_0-1673829394511.png

 

Hope that helps.

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe

View solution in original post

6 REPLIES 6
Solution
scottjm
Advisor

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:

scottjm_0-1673829394511.png

 

Hope that helps.

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe

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!

runxel
Legend

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.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»

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!

scottjm
Advisor

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.

 

 

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe

giphy

 

damn... That would be so useful