OSArch Community

[IfcOpenShell][BlenderBIM] Creating an IfcGrid,IfcBuildingStorey,IfcSlab,IfcWall and youtube demo.

  1. V

    @Moult said:

    This would be great to share on social media! By the way, IfcGridPlacement would be how to link objects to a grid's placement. However, it is not supported in IfcOpenShell.

    Any news on it? I believe, I can create IfcGridPlacement instead of IfcLocalPlacement and use it for IfcBuilding placement in ifcopenshell. But BlenderBIM couldn't load such IFC:

  2. V

    Well, I think I’ve found solution for myself. Just threw some middle-school equations in and now finding axes intersections explicitly:

    
    def find_axes_intersection(a1, a2):
    
        p11 = a1.AxisCurve.Points[0]
    
        p12 = a1.AxisCurve.Points[1]
    
        p21 = a2.AxisCurve.Points[0]
    
        p22 = a2.AxisCurve.Points[1]
    
        z0 = p11.Coordinates[2]
    
        x11 = p11.Coordinates[0]
    
        x12 = p12.Coordinates[0]
    
        y11 = p11.Coordinates[1]
    
        y12 = p12.Coordinates[1]
    
        x21 = p21.Coordinates[0]
    
        x22 = p22.Coordinates[0]
    
        y21 = p21.Coordinates[1]
    
        y22 = p22.Coordinates[1]
    
        A1 = y12 - y11
    
        B1 = x12 - x11
    
        C1 = y11 * (x12 - x11) - x11 * (y12 - y11)
    
        A2 = y22 - y21
    
        B2 = x22 - x21
    
        C2 = y21 * (x22 - x21) - x21 * (y22 - y21)
    
        x0 = (B1 * C2 - B2 * C1) / (A1 * B2 - A2 * B1)
    
        y0 = (C1 * A2 - C2 * A1) / (A1 * B2 - A2 * B1)
    
        return [x0,y0,z0]
    
    
    def create_customgridplacement(axis1, axis2, dir1=globalAxisZ, dir2=globalAxisX):
    
        point = ifc.createIfcCartesianPoint(find_axes_intersection(axis1, axis2))
    
        axis2Placement = ifc.createIfcAxis2Placement3D(point, dir1, dir2)
    
        localPlacement = ifc.createIfcLocalPlacement(None, axis2Placement)
    
        return localPlacement
    
  3. P

    When opening the IFC the Grids are contained to the site, from models exported from different sources I always see them related to the building storey, is there a reason why you've chosen to relate it to the site?

  4. C

    @Pahlawan

    is there a reason why you've chosen to relate it to the site?

    No specific reason, intuivitely seemed to be the most logic place.

  5. P

    @Coen said:

    @Pahlawan

    is there a reason why you've chosen to relate it to the site?

    No specific reason, intuivitely seemed to be the most logic place.

    Yeah also seems to work good if you add other models in for example Solibri the grids will be there on multiple floors if that model has elements on that floor. Strangely does not work when there are only slabs in the model, it’ll only project on the first floor. Don’t know if that’s a feature or a bug though.

  6. C

    Python code for create ifcGrid direct on BlenderBIM

    
     """
    
      #bpy.ops.bim.new_project(preset="metric_mm")
    
      Test_Create_Grid_01.py
    
    
    """
    
    
    import bpy
    
    import blenderbim.tool as tool
    
    import ifcopenshell
    
    
    from mathutils import Vector
    
    
    site = tool.Ifc.get().by_type("IfcSite")
    
    site = site[0]
    
    site_obj = tool.Ifc.get_object(site)
    
    
    obj = bpy.data.objects.new("Grid", None)
    
    obj.name = "Grid"
    
    
    collection = site_obj.BIMObjectProperties.collection
    
    collection.objects.link(obj)
    
    
    bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcGrid")
    
    grid = tool.Ifc.get_entity(obj)
    
    
    collection = obj.BIMObjectProperties.collection
    
    
    
    
    GridXList = [   {'id':'1' , 'distance':0.0 } ,
    
                    {'id':'2' , 'distance':4   },  
    
                    {'id':'3' , 'distance':7   },  ]
    
    
    GridYList = [   {'id':'A' , 'distance':0.0 } ,
    
                    {'id':'B' , 'distance':3.5 },
    
                    {'id':'C' , 'distance':5.5 },
    
                    {'id':'D' , 'distance':9.5},]
    
    
    common_keys = set.intersection(*map(set, GridXList))
    
    v = {k: [dic[k] for dic in GridXList] for k in common_keys}
    
    maxX = max(v['distance'])
    
    minX = min(v['distance'])
    
    
    common_keys = set.intersection(*map(set, GridYList))
    
    v = {k: [dic[k] for dic in GridYList] for k in common_keys}
    
    maxY = max(v['distance'])
    
    minY = min(v['distance'])
    
    
    
    
    axes_collection1 = bpy.data.collections.new("UAxes")
    
    collection.children.link(axes_collection1)
    
    
    
    
    for iGrid in GridYList:
    
        id = iGrid['id']
    
        y = iGrid['distance']
    
        verts = [
    
            Vector(( minX-2, y ,0)),
    
            Vector(( maxX+2, y ,0)),
    
        ]
    
        print(verts)
    
        edges = [[0, 1]]
    
        faces = []
    
        mesh = bpy.data.meshes.new(name="Grid Axis")
    
        mesh.from_pydata(verts, edges, faces)
    
        tag = id
    
        obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
    
        axes_collection1.objects.link(obj)
    
        result = ifcopenshell.api.run(
    
            "grid.create_grid_axis",
    
            tool.Ifc.get(),
    
            **{"axis_tag": tag, "uvw_axes": "UAxes", "grid": grid},
    
        )
    
        tool.Ifc.link(result, obj)
    
        ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), **{"axis_curve": obj, "grid_axis": result})
    
        obj.BIMObjectProperties.ifc_definition_id = result.id()
    
    
    axes_collection2 = bpy.data.collections.new("VAxes")
    
    collection.children.link(axes_collection2)
    
    
    for iGrid in GridXList:
    
        id = iGrid['id']
    
        x = iGrid['distance']
    
        verts = [
    
            Vector(( x , minY-2, 0)),
    
            Vector(( x , maxY+2, 0)),
    
        ]
    
        print(verts)
    
        edges = [[0, 1]]
    
        faces = []
    
        mesh = bpy.data.meshes.new(name="Grid Axis")
    
        mesh.from_pydata(verts, edges, faces)
    
        tag = id
    
        obj = bpy.data.objects.new(f"IfcGridAxis/{tag}", mesh)
    
        axes_collection2.objects.link(obj)
    
        result = ifcopenshell.api.run(
    
            "grid.create_grid_axis",
    
            tool.Ifc.get(),
    
            **{"axis_tag": tag, "uvw_axes": "VAxes", "grid": grid},
    
        )
    
        tool.Ifc.link(result, obj)
    
        ifcopenshell.api.run("grid.create_axis_curve", tool.Ifc.get(), **{"axis_curve": obj, "grid_axis": result})
    
        obj.BIMObjectProperties.ifc_definition_id = result.id()
    
    
  1. Page 1
  2. 2

Login or Register to reply.