[BlenderBIM] Create faces for IfcBuildingStorey

MaxMax
edited July 2022 in General

I am working in BlenderBIM and wonder if somebody knows how to create planes/faces for each IfcBuildingStorey? I am thinking of 10*10 m around 0,0 in a new collection. An other option would just be to get a list of all the IfcBuildingStoreys and make them manually.

Comments

  • I might not fully understand what you're asking, but you can assign a IfcBuildingStorey class to actual geometry.
    https://www.dropbox.com/s/c3rydbkmpytu1c0/2022-07-20_08-19-23_Blender_[CUsersOwnerDesktopuntitled.blend]_blender.mp4?dl=0

  • Do you mean something like this?

    I tested it on IFC_Schependomlaan.ifc:

    Then ran this little script:


    import bpy import ifcopenshell import blenderbim.bim.import_ifc from blenderbim.bim.ifc import IfcStore ifc_file = ifcopenshell.open(IfcStore.path) products = ifc_file.by_type('IfcProduct') for ifcproduct in products: if ifcproduct: if ifcproduct.is_a() == "IfcBuildingStorey": x = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[0]) y = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[1]) z = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[2]) bpy.ops.mesh.primitive_plane_add(size=50, enter_editmode=False, align='WORLD', location=(x, y, ifcproduct.Elevation/1000), scale=(1, 1, 1))

    The result in Blender:

    And export to IFC:

    Gorgiousbruno_perdigaotheoryshawbrunopostle
  • Thank a lot, the script works perfectly and is really useful. One thing that I wonder if it would be possible to name the planes after the storeys?

    Coen
  • edited July 2022

    @Max said:
    Thank a lot, the script works perfectly and is really useful. One thing that I wonder if it would be possible to name the planes after the storeys?

    Yes, just add
    bpy.context.active_object.name = str(ifcproduct.Name)
    at the end of the for loop, so the script now looks like this:

    import bpy
    import ifcopenshell
    import blenderbim.bim.import_ifc
    from blenderbim.bim.ifc import IfcStore
    
    
    ifc_file = ifcopenshell.open(IfcStore.path)
    products = ifc_file.by_type('IfcProduct')
    
    for ifcproduct in products:
    
        if ifcproduct:
    
            if ifcproduct.is_a() == "IfcBuildingStorey":
    
                x = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[0])
                y = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[1])
                z = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[2])
    
                print (x, y, z, ifcproduct.Elevation)
    
    
                print (ifcproduct.ObjectPlacement)
    
                bpy.ops.mesh.primitive_plane_add(size=50, enter_editmode=False, align='WORLD', location=(x, y, (ifcproduct.Elevation)/1000), scale=(1, 1, 1))
    
                bpy.context.active_object.name = str(ifcproduct.Name)
    
                bpy.ops.bim.assign_class(ifc_class="IfcBuildingElementProxy", predefined_type="", userdefined_type="")
    

    I also added the assignment of the IfcElement, I don't know yet how to assign the plane to each correct IfcBuidingStorey, the IfcOpenShell api is confusing me, I don't think it should be that hard. If the IfcProduct.Elevation isNone in some IFC models, you could try to use the z variable instead.

    EDIT:
    Just amazing how BlenderBIM is able to facilitate adding a plane in IFC in a relatively easy way. Imagine doing this in Revit, what a hassle that would be...The IFC model would still be loading....
    Little examples like this really show the added value of BlenderBIM.

  • edited July 2022

    ...I don't know yet how to assign the plane to each correct IfcBuidingStorey...

    I would like to know how to do this, as well.
    Maybe assign_product_representation , createIfcShapeRepresentation and createIfcProductDefinitionShape methods somehow? Total noobie.
    Thanks, @Coen, btw, for providing these little code snippets. Helps peeps learn a little at a time.

  • Something like this will add an Element to a storey:

            ifcopenshell.api.run(
                "spatial.assign_container",
                file,
                product=my_building_element,
                relating_structure=my_storey,
            )
    

    This will work for any Element (like a Wall, Slab etc..), if you want to add a Spatial Element (like a Space) to a Storey, you need to use "aggregate.assign_object" instead of "spatial.assign_container".

    Coen
  • Oh, that's what you mean.
    I thought you were asking to do something like this...

  • Hello,
    does it sort the ifc object to the storey?
    there is a ifcpatch recipe that does the storey seperation provided the objects are the right place. What if not? some walls declared in ground-floor, that need to be 'cutted' to each storey?
    If have problems to run ifcpatch within Blender on win10. A wiki article would be nice for win10 user to set up the environemnt within blender to be able to use all those BlenderBIM scripts and other python tools (which often need dependencies, like the prj for making drawings to inkspace).

Sign In or Register to comment.