Storey placement / elevation using ifcopenshell.api
Dear all,
I am very new to ifcopenshell, it is an amazing project!
I want to create an ifc file from scratch but I don't understand how to set the elevation of the building storeys in the root.create_entity
function.
for index, story in enumerate(stories):
elevation = story['data']['elevation']
storey = ifcopenshell.api.run("root.create_entity", ifcfile, ifc_class="IfcBuildingStorey", name= str(index + 1).zfill(2) + " " + "Storey")
ifcopenshell.api.run("aggregate.assign_object", ifcfile, relating_object=building, product=storey)
Could someone help me out?
Best!
Comments
Not an expert, just know where to look sometimes. :)
https://sourcegraph.com/search?q=context:global+createIfcBuildingStorey+lang:Python&patternType=regexp&case=yes&sm=0&groupBy=repo
Take particular note of @Coen's scripts.
https://sourcegraph.com/search?q=context:global+repo:^github\.com/C-Claus/BlenderScripts$+elevation&patternType=regexp&case=yes&sm=0&groupBy=path
Cool thank you! Looks like a great reference to look at also for other things
Do you know if setting the story elevation is also possible using the API , so with the
root.create_entity
function.The elevation is derived from the Z ordinate of the storey's placement. This means you should use the
geometry.edit_object_placement
API function and feed it a matrix.Awesome. Thank you @Moult !
When adding slabs tot the storey, do I have to repeat the process of
geometry.edit_object_placement
?I was thinking setting the slab position to (0.0, 0.0, 0.0) and assigning the slab object to the storey should do it as well
But i does not for the slabs

All slabs need to have their own origin too. You can leave them as 0,0,0 if you want:
One option to "model relatively" is to first model all the slabs with all the levels at 0,0,0, then move the levels to their elevation, which will move all the slabs with it if you set
should_transform_children=True
:Thank you @Moult !
Following this approach I still don't get the right global placement
Have you tried first setting your slab's origin to 0,0,0 and only afterwards shifting it up?
BTW containment is mutually exclusive to aggregation. Remove this:
... slabs should be contained in storeys, not aggregated in storeys (because a slab is not a part of a storey).
By the way there are also API functions to help with this:
This does the job
Thank you so much for your advice and patience!!
Cheers! Indeed you need to set the storey to 0,0,0 first so that it knows that children are relative to that 0,0,0, so that when you move it later, the children move with it.
You should also make sure your building / site / etc are set to 0,0,0 so that you have a proper tree of relative coordinates.