Importing custom Property Set Templates from spreadsheet file
Hi,
Has anyone imported and created custom Property Set Templates from spreadsheet files to Bonsai?
I have a ready spreadsheet file that has columns for Property Set's Name, Description and Type (IfcLabel etc.).
I tried to use ChatGPT to create such python script but AI just can't get a working code for me.
So, it this doable inside Bonsai scripting workspace?
Comments
@Samppa
you can import a schedule back to Bonsai with properties provided you have the GlobalID of the elements, can you elaborate more on the starting condition? an .ifc sample would be helpful
cheers
Thanks, tested exporting and importing property sets but couldn't figure out how to create new property set names. So after that I just created those manually. Probably I'll return to testing this more later on.
@Samppa please share here an example of custom pset you'd like to add
in the meantime :
1. did you check the pset already available?
2. you want to do it with Bonsai or in Python?
@steverugi here is the .odt file. I was able to create a custom property template file and then save most of these property sets from our country example projects in it (files were done in other bim software).
Your questions:
1. these custom property sets are required from ifc files in my country (if they are used for applying building permission)
2. I did try to do it inside Bonsai using scripting tab and copy pasting python code there.
@Samppa
odd, I used ifcopenshell.api.pset_template to create template and properties but they don't show in the UI, only manually
opening the .ifc file I can see they are there but not in Bonsai's UI
but you can still manually add any of the custom properties from property sets to your elements and with Spreadshett I/O can edit them in a .csv
please confirm
cheers
Hi @Samppa
I think I managed to sort it out (along with ChatGPT)
Original Request
Importing custom Property Set Templates from spreadsheet file ( I use .csv format here for simplicity)
Issue
the functions in ifcopenshell.api.pset_template are supposed to be used in conjunction with
to create a simple .ifc file with the Pset_template information, the same that Bonsai does when the user adds it manually in Project Setup > Property Set Templates.
I wish it were mentioned in the example here to help non-programmers like me in adopting some scripts in day-to-day tasks. Not a criticism, just an observation
Solution (?)
in this example a .csv table is used to organize the data, like:
and the same data is loaded in a Pandas table (dataframe) and converted to property set/property accordingly.
The final file is then saved in the folder where Bonsai reads all custom pset templates.
Video
Where I use .csv file and .py script to generate your template (all attached, you need to change the suffix) in Bonsai.
Please do not forget to update the script for csv_path and output_folder.
I would appreciate your feedback
cheers
note
forgot to mention that the code is for a single value properties, which is hard-coded in the script
Very nice, thank you so much Steve!

To use them for spatial elements like IfcSite and IfcBuilding I changed in ifc-file code IfcElement -> IfcObject and then it was possible to add property sets for spatial elements too. Quess this is ok?
This is script is very useful tool to add and update locally demanded extra psets. So thank you again.
I will test this more in the coming days.
All the best