import bpyimport ifcopenshellfrom ifcopenshell.api import runimport numpy# Create a blank modelmodel = ifcopenshell.file()# All projects must have one IFC Project elementproject = run("root.create_entity", model, ifc_class="IfcProject", name="My Project")# Geometry is optional in IFC, but because we want to use geometry in this example, let's define units# Assigning without arguments defaults to metric unitsrun("unit.assign_unit", model)# Let's create a modeling geometry context, so we can store 3D geometry (note: IFC supports 2D too!)context = run("context.add_context", model, context_type="Model")# In particular, in this example we want to store the 3D "body" geometry of objects, i.e. the body shapebody = run("context.add_context", model, context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=context)# Create a site, building, and storey. Many hierarchies are possible.site = run("root.create_entity", model, ifc_class="IfcSite", name="My Site")building = run("root.create_entity", model, ifc_class="IfcBuilding", name="Building A")storey = run("root.create_entity", model, ifc_class="IfcBuildingStorey", name="Ground Floor")# Since the site is our top level location, assign it to the project# Then place our building on the site, and our storey in the buildingrun("aggregate.assign_object", model, relating_object=project, product=site)run("aggregate.assign_object", model, relating_object=site, product=building)run("aggregate.assign_object", model, relating_object=building, product=storey)# in this part we define some values for our position matrixx=1y=2z=0rot = 0rotw = 20# opening offset o and the elevation zwo=1zw = 0.5# Geometry properties - wall length, height, tickness, window/opening length, window/heigth length, l=5h=2.4t=0.25lw=0.9hw =2.1# Create a 4x4 identity matrix. This matrix is at the origin with no rotation.matrix = numpy.eye(4)matrixw = numpy.eye(4)matrixp = numpy.eye(4)# Rotate the matix (rot) degrees (ex. 90 degrees) anti-clockwise around the Z axis (i.e. in plan).# Anti-clockwise is positive. Clockwise is negative.matrix = ifcopenshell.util.placement.rotation(rot, "Z") @ matrixmatrixw = ifcopenshell.util.placement.rotation(rot, "Z") @ matrixwmatrixw = ifcopenshell.util.placement.rotation(rotw, "X") @ matrixwmatrixp = ifcopenshell.util.placement.rotation(rot, "Z") @ matrixwmatrixp = ifcopenshell.util.placement.rotation(0, "X") @ matrixw# Set the X, Y, Z coordinates. Notice how we rotate first then translate.# This is because the rotation origin is always at 0, 0, 0.matrix[:,3][0:3] = (x, y, z)matrixw[:,3][0:3] = (x, y, z+3-0.1)matrixp[:,3][0:3] = (x, y, z+3-0.1)column = run("root.create_entity", model, ifc_class="IfcColumn", name="ColE"+str(1))profile = model.create_entity("IfcIShapeProfileDef", ProfileName="I-EXAMPLE", ProfileType="AREA", OverallWidth=100, OverallDepth=200, WebThickness=10, FlangeThickness=15, FilletRadius=10)# A profile-based representation, 3 meter longrepresentation = run("geometry.add_profile_representation", model, context=body, profile=profile, depth=3) # Assign our new body geometry back to our columnrun("geometry.assign_representation", model, product=column, representation=representation)column2 = run("root.create_entity", model, ifc_class="IfcColumn", name="ColP"+str(1))# Rectangles (or squares) are typically used for concrete columns and beamsprofile2 = model.create_entity("IfcRectangleProfileDef", ProfileName="600x300", ProfileType="AREA", XDim=200, YDim=300)# A profile-based representation, 1 meter longrepresentation = run("geometry.add_profile_representation", model, context=body, profile=profile2, depth=0.01) # Assign our new body geometry back to our wallrun("geometry.assign_representation", model, product=column2, representation=representation) # Assign the column to our coordinates defined by the matrixrun("geometry.edit_object_placement", model, product=column, matrix=matrix, is_si=True) # Assign the walls to our coordinates defined by the matrixrun("geometry.edit_object_placement", model, product=column2, matrix=matrixp, is_si=True)# Let's prepare a steel material. Note that our concrete material# does not have any colours (styles) at this point.steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")# Assign our steel material to our columnifcopenshell.api.run("material.assign_material", model, product=column, type="IfcMaterial", material=steel)# Create a new surface stylestyle = ifcopenshell.api.run("style.add_style", model)# Create a simple shading colour and transparency.ifcopenshell.api.run("style.add_surface_style", model, style=style, ifc_class="IfcSurfaceStyleShading", attributes={ "SurfaceColour": { "Name": None, "Red": 1, "Green": 0.2, "Blue": 0},"Transparency": 0.5, # 0 is opaque, 1 is transparent })# Now any element (like our column) with a concrete material will have# a yellow colour applied.ifcopenshell.api.run("style.assign_material_style", model, material=steel, style=style, context=body)# Wall opening - door example# Create an opening, doors, windows and so onopening = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcOpeningElement")# Rectangles (or squares) are typically used for concrete columns and beamsprofile3 = model.create_entity("IfcRectangleProfileDef", ProfileName="600xr00", ProfileType="AREA", XDim=2000, YDim=2000)# A profile-based representation, 1 meter longrepresentation = run("geometry.add_profile_representation", model, context=body, profile=profile3, depth=1) # Assign our new body geometry back to our wallrun("geometry.assign_representation", model, product=opening, representation=representation)# Let us create an opening representation of a 950mm x 2100mm door.# Notice how the thickness is greater than the wall thickness, this# helps resolve floating point resolution errors in 3D. # Assign the walls to our coordinates defined by the matrixrun("geometry.edit_object_placement", model, product=opening, matrix=matrixw, is_si=True)#Here we assing the opening to our wallifcopenshell.api.run("void.add_opening", model, opening=opening, element=wall)# Assign the slab to the spacial structure (storey)rel_contained_in_spatial_structure = model.createIfcRelContainedInSpatialStructure(GlobalId = ifcopenshell.guid.new(), RelatedElements = [wall], RelatingStructure=storey)model.write("C:\\Users\\ciunt\\OneDrive\\Desktop\\test.ifc")bpy.ops.bim.load_project(filepath="C:\\Users\\ciunt\\OneDrive\\Desktop\\test.ifc", use_relative_path=False, should_start_fresh_session=False)
1 thought on “I column profile cut with steel plate”
Hi Ionut,
Rog daca poti verifica entitate “wall” in codul de mai sus unde este (am impresisa ca a fost omisa) ?
Hi Ionut,
Rog daca poti verifica entitate “wall” in codul de mai sus unde este (am impresisa ca a fost omisa) ?
Ms