import bpy import numpy as np import os import random import math # =========================================== filePathSTL = r"D:\DOTTORATO\0000_WORK\0010_BLENDER_BIM\0000_WORK\2024_02_06\STL" nameSTL = "Accropode.STL" # =========================================== filePathTXT = r"D:\DOTTORATO\0000_WORK\0010_BLENDER_BIM\0000_WORK\2024_02_06\TXT" nameTXT = "rotazioni_accropodi.txt" fileIn = os.path.join(filePathTXT,nameTXT) data = np.loadtxt(fileIn, skiprows=1, unpack = True) # Rotation values according to the different axes phiX = np.asarray(np.squeeze(data[0])) phiY = np.asarray(np.squeeze(data[1])) phiZ = np.asarray(np.squeeze(data[2])) nRot = phiX.shape[0] #====================================================== # Time simulation parameters start_f = 1 end_f = 500 mult_delay = 20 #====================================================== bpy.context.scene.frame_end = end_f try: bpy.ops.rigidbody.world_add() except: print("Rigid body world already checked") pass bpy.context.scene.gravity = (0., 0., -1.) bpy.context.scene.rigidbody_world.point_cache.frame_start = start_f bpy.context.scene.rigidbody_world.point_cache.frame_end = end_f #====================================================== BuildStructure = True # STRUCTURE MODELING # if BuildStructure: xC = 1.0 Lc = 26.0 xCsup = xC + Lc yC = 15.60 yCsup = 4.5 z = 0.0 z2 = 1.0 zCsup = 8.30 verts = [(-xC, -yC, z), (-xC, yC, z), (xCsup, -yC, z), (xCsup, yC, z), (-xC, -yCsup, zCsup), (-xC, yCsup, zCsup), (xCsup, -yCsup, zCsup), (xCsup, yCsup, zCsup)] faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="New Mesh") mesh.from_pydata(verts, [], faces) const = bpy.data.objects.new('Const', mesh) scene = bpy.context.scene scene.collection.objects.link(const) # FIRST LAYER MODELING # x = 0.0 L = 25.0 xSup = x + L y1L = 17.25 y1Lsup = 4.85 z1Lsup = 9.3 layer_verts = [(x, -y1L, z), (x, y1L, z), (xSup, -y1L, z), (xSup, y1L, z), (x, -y1Lsup, z1Lsup), (x, y1Lsup, z1Lsup), (xSup, -y1Lsup, z1Lsup), (xSup, y1Lsup, z1Lsup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="under_Layer") mesh.from_pydata(layer_verts, [], layer_faces) filter = bpy.data.objects.new('under_Layer', mesh) scene = bpy.context.scene scene.collection.objects.link(filter) # Make filter layer active in way to apply boolean modifier bpy.data.objects['under_Layer'].select_set(False) bpy.context.view_layer.objects.active = filter bpy.ops.object.modifier_add(type = 'BOOLEAN') bpy.context.object.modifiers["Boolean"].object = const bpy.ops.object.modifier_apply(modifier = 'Boolean') # Select construction layer to delete it bpy.data.objects["Const"].select_set(True) bpy.ops.object.delete() # CORE MODELING # core_verts = [(x, -yC, z), (x, yC, z), (xSup, -yC, z), (xSup, yC, z), (x, -yCsup, zCsup), (x, yCsup, zCsup), (xSup, -yCsup, zCsup), (xSup, yCsup, zCsup)] core_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Core") mesh.from_pydata(core_verts, [], core_faces) core = bpy.data.objects.new('Core', mesh) scene = bpy.context.scene scene.collection.objects.link(core) core.name = "Core" # Compute Core Volume coreArea = (((yC*2) + (yCsup*2))/2) * zCsup coreVolume = coreArea * L # left side of the under layer yUL = 15.58 yULSup = 35.74 yULInf = 37.23 layer_verts = [(x, -yUL, z), (x, -yULInf, z), (xSup, -yUL, z), (xSup, -yULInf, z), (x, -yUL, z2), (x, -yULSup, z2), (xSup, -yUL, z2), (xSup, -yULSup, z2)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="under_LayerSx") mesh.from_pydata(layer_verts, [], layer_faces) underLayerSx = bpy.data.objects.new('under_LayerSx', mesh) scene = bpy.context.scene scene.collection.objects.link(underLayerSx) # right side of the under layer layer_verts = [(x, yUL, z), (x, yULInf, z), (xSup, yUL, z), (xSup, yULInf, z), (x, yUL, z2), (x, yULSup, z2), (xSup, yUL, z2), (xSup, yULSup, z2)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="under_LayerDx") mesh.from_pydata(layer_verts, [], layer_faces) underLayerDx = bpy.data.objects.new('under_LayerDx', mesh) scene = bpy.context.scene scene.collection.objects.link(underLayerDx) # Select layers to join them bpy.data.objects["under_Layer"].select_set(True) bpy.data.objects["under_LayerSx"].select_set(True) bpy.data.objects["under_LayerDx"].select_set(True) bpy.ops.object.join() bpy.ops.object.select_all(action='DESELECT') filter.name = "UnderLayer" # Compute volume Under Layer yULSupDX = 15.9 bInfULBerm = yULInf - yC bSupULBerm = yULSup - yULSupDX UnderLayerBerm_A = ((bInfULBerm+bSupULBerm)/2)*z2 bInfULSide = np.sqrt((yC-yCsup)**2 + zCsup**2) bSupULSide = np.sqrt((yULSupDX-yCsup)**2 + (z1Lsup-z2)**2) UnderLayerSide = ((bInfULSide + bSupULSide)/2)*z2 bInfUpperSide = yC * 2 bSupUpperSide = y1Lsup * 2 UnderLayerUp = ((yC + y1Lsup)/2)*z2 UnderLayerVol = ((UnderLayerBerm_A*2)+(UnderLayerSide*2)+UnderLayerUp)*L # SECOND FILTER LAYER MODELING # # left side of the filter layer y2Lside = 18.90 y2LsideInt = 15.90 y2LsideSup = 5.45 y2LsideSupInt = 2.45 z2LsideSup = 11.10 layer_verts = [(x, -y2Lside, z2), (x, -y2LsideInt, z2), (xSup, -y2Lside, z2), (xSup, -y2LsideInt, z2), (x, -y2LsideSup, z2LsideSup), (x, -y2LsideSupInt, z2LsideSup), (xSup, -y2LsideSup, z2LsideSup), (xSup, -y2LsideSupInt, z2LsideSup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Filter_layer2sx") mesh.from_pydata(layer_verts, [], layer_faces) filter2sx = bpy.data.objects.new('Filter_layer2sx', mesh) scene = bpy.context.scene scene.collection.objects.link(filter2sx) # right side of the filter layer layer_verts = [(x, y2Lside, z2), (x, y2LsideInt, z2), (xSup, y2Lside, z2), (xSup, y2LsideInt, z2), (x, y2LsideSup, z2LsideSup), (x, y2LsideSupInt, z2LsideSup), (xSup, y2LsideSup, z2LsideSup), (xSup, y2LsideSupInt, z2LsideSup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Filter_layer2dx") mesh.from_pydata(layer_verts, [], layer_faces) filter2dx = bpy.data.objects.new('Filter_layer2dx', mesh) scene = bpy.context.scene scene.collection.objects.link(filter2dx) # upper side of the filter layer yUpd = 5.45 layer_verts = [(x, -yUpd, z1Lsup), (x, yUpd, z1Lsup), (xSup, -yUpd, z1Lsup), (xSup, yUpd, z1Lsup), (x, -yUpd, z2LsideSup), (x, yUpd, z2LsideSup), (xSup, -yUpd, z2LsideSup), (xSup, yUpd, z2LsideSup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Filter_Layer") mesh.from_pydata(layer_verts, [], layer_faces) filter_layer2 = bpy.data.objects.new('Filter_Layer', mesh) scene = bpy.context.scene scene.collection.objects.link(filter_layer2) # Select layers to join them bpy.context.view_layer.objects.active = filter_layer2 bpy.data.objects["Filter_layer2sx"].select_set(True) bpy.data.objects["Filter_layer2dx"].select_set(True) bpy.data.objects["Filter_Layer"].select_set(True) bpy.ops.object.join() bpy.ops.object.select_all(action='DESELECT') filter_layer2.name = "FilterLayer" # Compute volume of the filter layer bInfLayerSide = np.sqrt((y2LsideInt - y1Lsup)**2 + (z1Lsup - z2)**2) bSupLayerSide = np.sqrt((y2Lside - yUpd)**2 + (z2LsideSup - z2)**2) AsupLayerSide = ((bSupLayerSide + bInfLayerSide)/2) * (z2LsideSup - z1Lsup) AupperSideLayer = (((y1Lsup * 2) + (yUpd * 2))/2) * (z2LsideSup - z1Lsup) VfilterLayer = ((AsupLayerSide * 2) + AupperSideLayer) * L # BERM MODELING # # Berm on the left side yB = 22.35 yBSup = 26.15 yBInf = 29.0 zBSup = 3.0 layer_verts = [(x, -yB, z2), (x, -yBInf, z2), (xSup, -yB, z2), (xSup, -yBInf, z2), (x, -yB, zBSup), (x, -yBSup, zBSup), (xSup, -yB, zBSup), (xSup, -yBSup, zBSup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Berm_SX") mesh.from_pydata(layer_verts, [], layer_faces) bermSX = bpy.data.objects.new('Berm_SX', mesh) scene = bpy.context.scene scene.collection.objects.link(bermSX) bermSX.name = "BermSX" # Berm on the right side layer_verts = [(x, yB, z2), (x, yBInf, z2), (xSup, yB, z2), (xSup, yBInf, z2), (x, yB, zBSup), (x, yBSup, zBSup), (xSup, yB, zBSup), (xSup, yBSup, zBSup)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="Berm_DX") mesh.from_pydata(layer_verts, [], layer_faces) bermDX = bpy.data.objects.new('Berm_DX', mesh) scene = bpy.context.scene scene.collection.objects.link(bermDX) bermDX.name = "BermDX" # Compute Berms Volume bInfBerm = yBInf - yB bSupBerm = yBSup - yB AreaBerm = ((bInfBerm + bSupBerm)/2) * (zBSup - z2) BermVolume = AreaBerm * L # WALL MODELING # yW = 37.23 yWl = 37.23 yWlength = yW + yWl xW = 26.0 s = 0.5 xWallSup = xW + s zWall = 15.0 layer_verts = [(xW, yW, z), (xW, -yWlength, z), (xWallSup, yW, z), (xWallSup, -yWlength, z), (xW, yW, zWall), (xW, -yWlength, zWall), (xWallSup, yW, zWall), (xWallSup, -yWlength, zWall)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="WallDX") mesh.from_pydata(layer_verts, [], layer_faces) wallDX = bpy.data.objects.new('WallDX', mesh) scene = bpy.context.scene scene.collection.objects.link(wallDX) wallDX.name = "Wall_DX" xWSX = 1 layer_verts = [(-xWSX, yW, z), (-xWSX, -yWlength, z), (-xWSX-s, yW, z), (-xWSX-s, -yWlength, z), (-xWSX, yW, zWall), (-xWSX, -yWlength, zWall), (-xWSX-s, yW, zWall), (-xWSX-s, -yWlength, zWall)] layer_faces = [[0, 2, 3, 1], [4, 6, 7, 5], [1, 5, 7, 3], [0, 4, 6, 2], [2, 6, 7, 3], [0, 4, 5, 1]] mesh = bpy.data.meshes.new(name="WallSX") mesh.from_pydata(layer_verts, [], layer_faces) wallSX = bpy.data.objects.new('WallSX', mesh) scene = bpy.context.scene scene.collection.objects.link(wallSX) wallSX.name = "Wall_SX" # MAKE RIGID BODY ALL ELEMENTS OF THE STRUCTURE # objects = [core, filter, filter_layer2, bermDX, bermSX, wallDX, wallSX] for obj in objects: bpy.context.view_layer.objects.active = obj bpy.ops.object.modifier_add(type = "SOLIDIFY") bpy.ops.object.modifier_apply(modifier = "Solidify") bpy.ops.rigidbody.object_add() rigid_body = obj.rigid_body rigid_body.type = "PASSIVE" rigid_body.collision_shape = "MESH" obj.select_set(False) # GRID ACCROPODES BUILDING # # Phisic parameters mass = 1000. d = 0.2 f = 0.8 xIn = 1.5 # coordinata x primo accropode yIn = -20.35 # coordinata y primo accropode Dn = 3. # Numerical diameter [m] V = 4.0 # Numerical volume [TO DO ....] nrows = 6. # Number of accropode according to x axes ncolumns = 6. # Number of accropode according to y axes a = 0.60 * 2.5 # Spacing between accropode according to x axes b = 1.20 # Spacing between accropode according to y axes c = 0.5 * 2 # Spacing between accropode according to z axes # First element coordinate x1 = (Dn*nrows/2.+(nrows/2-1)*(a-1)*Dn)+(a-1)*Dn bSupLayerSide = (Dn*ncolumns/2.+(ncolumns/2-1)*(b-1)*Dn)+(b-1)*Dn/2.0 z0 = 2.0 # z0 = .05 dz = 3. #================================================================ # Grid of accropodes # xx = 0 yy = 0 cont = -1 xx = np.arange(xIn, xIn+a*Dn*nrows, a*Dn) yy = np.arange(yIn, yIn+b*Dn*ncolumns, b*Dn) # yy = np.asarray([yy[quale]]) data = [] for iy,y in enumerate(yy): for ix,x in enumerate(xx): yToPut = -y zz = z0 + iy * dz # zz = z0 if (iy+1) % 2 == 0: xToPut = x + a * Dn/2.0 if ix < len(xx)-1: data.append([xToPut,yToPut,zz]) else: xToPut = x data.append([xToPut,yToPut,zz]) lines = len(data) for iy,y in enumerate(yy): for ix,x in enumerate(xx): yToPut = y zz = z0 + iy * dz # zz = z0 if (iy+1) % 2 == 0: xToPut = x + a * Dn/2.0 if ix < len(xx)-1: data.append([xToPut,yToPut,zz]) else: xToPut = x data.append([xToPut,yToPut,zz]) pickRotPrev = 0 frame_interval = 20 ArmourLayer = True if ArmourLayer: for i,pos in enumerate(data): accropode_mesh = bpy.ops.import_mesh.stl( filepath=filePathSTL, filter_glob="*.stl", files=[{"name":nameSTL}], directory=filePathSTL) bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME', center='MEDIAN') bpy.context.active_object.dimensions = (Dn,Dn,Dn) # Calculate the rotation angles based on the phiX, phiY, and phiZ arrays pickRot = pickRotPrev while pickRot==pickRotPrev: pickRot = np.random.randint(0, nRot) pickRotPrev = pickRot rotation_x = phiX[pickRot] rotation_y = phiY[pickRot] rotation_z = phiZ[pickRot] # Apply the rotations to the object bpy.ops.transform.rotate( value=rotation_z, orient_axis='Z', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True ) bpy.ops.transform.rotate( value=rotation_x, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True ) bpy.ops.transform.rotate( value=rotation_y, orient_axis='Y', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, release_confirm=True ) bpy.ops.transform.translate(value=(pos[0], pos[1], pos[2]), #orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, False, True), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False) # ======================================================================= bpy.ops.object.select_all(action='DESELECT') # Deselects all objects on the scene accropode = bpy.data.objects['Accropode'] # Create for accropode accropode.select_set(True) # Selects only the accropode accropode.name = "AccropodeFinal" bpy.context.view_layer.objects.active = accropode # Assign the rigid body properties to accropode bpy.ops.rigidbody.object_add() # Adds rigid body to accropode rigid_body = accropode.rigid_body rigid_body.type = 'ACTIVE' rigid_body.collision_shape = "CONVEX_HULL" rigid_body.collision_margin = 0.01 rigid_body.mass = mass rigid_body.friction = f rigid_body.linear_damping = d accropode_objects = [obj for obj in bpy.data.objects if obj.name.startswith("Accropode")] accropode_objects.sort(key=lambda obj: obj.location.z) RunSimulation = True if RunSimulation: frame_interval = 5 # Increase this value to slow down the fall for index, accropode in enumerate(accropode_objects, start=1): frame = index * frame_interval accropode.rigid_body.linear_damping = d bpy.context.scene.frame_set(frame) accropode.rigid_body.kinematic = True # Make it kinematic (static) accropode.keyframe_insert(data_path = "rigid_body.kinematic", frame = frame - frame_interval) accropode.rigid_body.kinematic = False # Make it dynamic accropode.keyframe_insert(data_path = "rigid_body.kinematic", frame = frame) for frame in range(1, end_f+1): bpy.context.scene.frame_current = frame bpy.ops.object.visual_transform_apply() bpy.context.scene.frame_set(end_f) #time.sleep(0.1) frame = end_f bpy.context.scene.frame_set(frame) for accropode in accropode_objects: accropode.select_set(True) bpy.ops.object.visual_transform_apply() #====================================================== wallDelete = True if wallDelete: bpy.ops.object.select_all(action='DESELECT') wallList = [wallDX, wallSX] for walls in wallList: walls.select_set(True) bpy.ops.object.delete() # ===================================================== createBIMproject = True if createBIMproject: bpy.ops.bim.create_project() # It creates BIM project bpy.context.scene.BIMProjectProperties.author_name = "Valerio Gianforte" bpy.context.scene.BIMProjectProperties.organisation_name = "LIam" bpy.context.scene.BIMProjectProperties.author_email = "valerio.gianforte@graduate.univaq.it" objects = [core, filter, filter_layer2, bermDX, bermSX] IfcBuilding = bpy.data.collections["IfcBuilding/My Building"] sub_coll = bpy.data.collections.new("IfcStructureLayers/My Layers Structure") IfcBuilding.children.link(sub_coll) IfcStorey = bpy.data.collections["IfcBuildingStorey/My Storey"] sub_coll2 = bpy.data.collections.new("IfcArmourLayer/My Armour Layer") IfcStorey.children.link(sub_coll2) for accropode in accropode_objects: # BIM properties # bpy.context.view_layer.objects.active = accropode bpy.context.scene.BIMRootProperties.ifc_product = "IfcElement" bpy.context.scene.BIMRootProperties.ifc_class = "IfcCivilElement" bpy.ops.bim.assign_class(ifc_class = "IfcCivilElement", predefined_type = "IfcCivilElementType", userdefined_type = "") bpy.data.objects["IfcCivilElement/AccropodeFinal"].BIMTypeProperties.relating_type_class = "IfcCivilElementType" sub_coll2.objects.link(accropode) accropode.select_set(False) accropodeCollection = bpy.data.collections["IfcArmourLayer/My Armour Layer"].objects for acc in accropodeCollection: bpy.context.view_layer.objects.active = acc # PSET ELEMENT STATUS statusAC = bpy.context.scene.AddEditProperties.add() statusAC.pset_name = "Pset_InstallationPhasing" statusAC.property_name = "Status" statusAC.string_value = "NEW" statusAC.primary_measure_type = 'IfcGloballyUniqueId' statusAC.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") # PSET INSTALLATION PHASING phasing = bpy.context.scene.AddEditProperties.add() phasing.pset_name = "Pset_InstallationPhasing" phasing.property_name = "Work description" phasing.string_value = "Accropodes installation" phasing.primary_measure_type = 'IfcGloballyUniqueId' phasing.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") phasing = bpy.context.scene.AddEditProperties.add() phasing.pset_name = "Pset_InstallationPhasing" phasing.property_name = "Starting date" phasing.string_value = "20/07/2024" phasing.primary_measure_type = 'IfcGloballyUniqueId' phasing.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") phasing = bpy.context.scene.AddEditProperties.add() phasing.pset_name = "Pset_InstallationPhasing" phasing.property_name = "Ending date" phasing.string_value = "31/08/2024" phasing.primary_measure_type = 'IfcGloballyUniqueId' phasing.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") phasing = bpy.context.scene.AddEditProperties.add() phasing.pset_name = "Pset_InstallationPhasing" phasing.property_name = "Total work days" phasing.string_value = "43" phasing.primary_measure_type = 'IfcGloballyUniqueId' phasing.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") # GENERAL DATA psetGenaralData = "GENERAL DATA" psetArmourCost = bpy.context.scene.AddEditProperties.add() psetArmourCost.pset_name = psetGenaralData psetArmourCost.property_name = "Manifacturing" psetArmourCost.string_value = "Cast in place accropode" psetArmourCost.primary_measure_type = 'IfcGloballyUniqueId' psetArmourCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") psetArmourCost = bpy.context.scene.AddEditProperties.add() psetArmourCost.pset_name = psetGenaralData psetArmourCost.property_name = "Material" psetArmourCost.string_value = "Concrete" psetArmourCost.primary_measure_type = 'IfcGloballyUniqueId' psetArmourCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") psetArmourCost = bpy.context.scene.AddEditProperties.add() psetArmourCost.pset_name = psetGenaralData psetArmourCost.property_name = "Class of material" psetArmourCost.string_value = "C25/30" psetArmourCost.primary_measure_type = 'IfcGloballyUniqueId' psetArmourCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") psetArmourCost = bpy.context.scene.AddEditProperties.add() psetArmourCost.pset_name = psetGenaralData psetArmourCost.property_name = "Volume [m3]" psetArmourCost.string_value = str(V) psetArmourCost.primary_measure_type = 'IfcGloballyUniqueId' psetArmourCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/AccropodeFinal", obj_type="Object") for obj in objects: bpy.context.view_layer.objects.active = obj bpy.context.scene.BIMRootProperties.ifc_product = "IfcElement" bpy.context.scene.BIMRootProperties.ifc_class = "IfcCivilElement" bpy.ops.bim.assign_class(ifc_class = "IfcCivilElement", predefined_type = "IfcCivilElementType", userdefined_type = "") sub_coll.objects.link(obj) obj.select_set(False) #====================================================== objCollection = bpy.data.collections["IfcStructureLayers/My Layers Structure"].objects for c in objCollection: bpy.context.view_layer.objects.active = c if c.name.startswith("IfcCivilElement/Core"): # CORE PROPERTIES # # Pset Installation phasing statusCore = bpy.context.scene.AddEditProperties.add() statusCore.pset_name = "Pset_InstallationPhasing" statusCore.property_name = "Status" statusCore.string_value = "NEW" statusCore.primary_measure_type = 'IfcGloballyUniqueId' statusCore.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") statusCore = bpy.context.scene.AddEditProperties.add() statusCore.pset_name = "Pset_InstallationPhasing" statusCore.property_name = "Work description" statusCore.string_value = "Tout venant rock installation" statusCore.primary_measure_type = 'IfcGloballyUniqueId' statusCore.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") phasingCore = bpy.context.scene.AddEditProperties.add() phasingCore.pset_name = "Pset_InstallationPhasing" phasingCore.property_name = "Starting date" phasingCore.string_value = "01/04/2024" phasingCore.primary_measure_type = 'IfcGloballyUniqueId' phasingCore.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") phasingCore = bpy.context.scene.AddEditProperties.add() phasingCore.pset_name = "Pset_InstallationPhasing" phasingCore.property_name = "Ending date" phasingCore.string_value = "30/04/2024" phasingCore.primary_measure_type = 'IfcGloballyUniqueId' phasingCore.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") phasingCore = bpy.context.scene.AddEditProperties.add() phasingCore.pset_name = "Pset_InstallationPhasing" phasingCore.property_name = "Total work days" phasingCore.string_value = "30" phasingCore.primary_measure_type = 'IfcGloballyUniqueId' phasingCore.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") # General data psetGenaralData = "GENERAL DATA" psetCoreCost = bpy.context.scene.AddEditProperties.add() psetCoreCost.pset_name = psetGenaralData psetCoreCost.property_name = "Manifacturing" psetCoreCost.string_value = "Natural rock extracted from quarries" psetCoreCost.primary_measure_type = 'IfcGloballyUniqueId' psetCoreCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") psetCoreCost = bpy.context.scene.AddEditProperties.add() psetCoreCost.pset_name = psetGenaralData psetCoreCost.property_name = "Material" psetCoreCost.string_value = "Natural rock" psetCoreCost.primary_measure_type = 'IfcGloballyUniqueId' psetCoreCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") psetCoreCost = bpy.context.scene.AddEditProperties.add() psetCoreCost.pset_name = psetGenaralData psetCoreCost.property_name = "Volume [m3]" psetCoreCost.string_value = str(coreVolume) psetCoreCost.primary_measure_type = 'IfcGloballyUniqueId' psetCoreCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/Core", obj_type="Object") if c.name.startswith("IfcCivilElement/BermDX"): # BERM DX PROPERTIES # # Pset Installation phasing statusBermDX = bpy.context.scene.AddEditProperties.add() statusBermDX.pset_name = "Pset_InstallationPhasing" statusBermDX.property_name = "Status" statusBermDX.string_value = "NEW" statusBermDX.primary_measure_type = 'IfcGloballyUniqueId' statusBermDX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") phasingBermDX = bpy.context.scene.AddEditProperties.add() phasingBermDX.pset_name = "Pset_InstallationPhasing" phasingBermDX.property_name = "Working description" phasingBermDX.string_value = "Rock installation for berm building" phasingBermDX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermDX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") phasingBermDX = bpy.context.scene.AddEditProperties.add() phasingBermDX.pset_name = "Pset_InstallationPhasing" phasingBermDX.property_name = "Starting date" phasingBermDX.string_value = "01/06/2024" phasingBermDX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermDX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") phasingBermDX = bpy.context.scene.AddEditProperties.add() phasingBermDX.pset_name = "Pset_InstallationPhasing" phasingBermDX.property_name = "Ending date" phasingBermDX.string_value = "15/06/2024" phasingBermDX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermDX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") phasingBermDX = bpy.context.scene.AddEditProperties.add() phasingBermDX.pset_name = "Pset_InstallationPhasing" phasingBermDX.property_name = "Total work days" phasingBermDX.string_value = "15" phasingBermDX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermDX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") # General data psetGenaralData = "GENERAL DATA" psetBermDXCost = bpy.context.scene.AddEditProperties.add() psetBermDXCost.pset_name = psetGenaralData psetBermDXCost.property_name = "Manifacturing" psetBermDXCost.string_value = "Natural rock extracted from quarries" psetBermDXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermDXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") psetBermDXCost = bpy.context.scene.AddEditProperties.add() psetBermDXCost.pset_name = psetGenaralData psetBermDXCost.property_name = "Material" psetBermDXCost.string_value = "Natural rock" psetBermDXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermDXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") psetBermDXCost = bpy.context.scene.AddEditProperties.add() psetBermDXCost.pset_name = psetGenaralData psetBermDXCost.property_name = "Volume [m3]" psetBermDXCost.string_value = str(BermVolume) psetBermDXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermDXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermDX", obj_type="Object") if c.name.startswith("IfcCivilElement/BermSX"): # BERM SX PROPERTIES # # Pset Installation phasing statusBermSX = bpy.context.scene.AddEditProperties.add() statusBermSX.pset_name = "Pset_InstallationPhasing" statusBermSX.property_name = "Status" statusBermSX.string_value = "NEW" statusBermSX.primary_measure_type = 'IfcGloballyUniqueId' statusBermSX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") phasingBermSX = bpy.context.scene.AddEditProperties.add() phasingBermSX.pset_name = "Pset_InstallationPhasing" phasingBermSX.property_name = "Work description" phasingBermSX.string_value = "Rock installation for berm building" phasingBermSX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermSX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") phasingBermSX = bpy.context.scene.AddEditProperties.add() phasingBermSX.pset_name = "Pset_InstallationPhasing" phasingBermSX.property_name = "Starting date" phasingBermSX.string_value = "01/06/2024" phasingBermSX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermSX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") phasingBermSX = bpy.context.scene.AddEditProperties.add() phasingBermSX.pset_name = "Pset_InstallationPhasing" phasingBermSX.property_name = "Ending date" phasingBermSX.string_value = "15/06/2024" phasingBermSX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermSX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") phasingBermSX = bpy.context.scene.AddEditProperties.add() phasingBermSX.pset_name = "Pset_InstallationPhasing" phasingBermSX.property_name = "Total work days" phasingBermSX.string_value = "15" phasingBermSX.primary_measure_type = 'IfcGloballyUniqueId' phasingBermSX.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") # General data psetGenaralData = "GENERAL DATA" psetBermSXCost = bpy.context.scene.AddEditProperties.add() psetBermSXCost.pset_name = psetGenaralData psetBermSXCost.property_name = "Manifacturing" psetBermSXCost.string_value = "Natural rock extracted from quarries" psetBermSXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermSXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") psetBermSXCost = bpy.context.scene.AddEditProperties.add() psetBermSXCost.pset_name = psetGenaralData psetBermSXCost.property_name = "Material" psetBermSXCost.string_value = "Natural rock" psetBermSXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermSXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") psetBermSXCost = bpy.context.scene.AddEditProperties.add() psetBermSXCost.pset_name = psetGenaralData psetBermSXCost.property_name = "Volume [m3]" psetBermSXCost.string_value = str(BermVolume) psetBermSXCost.primary_measure_type = 'IfcGloballyUniqueId' psetBermSXCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/BermSX", obj_type="Object") if c.name.startswith("IfcCivilElement/FilterLayer"): # FILTER PROPERTIES # # Pset Installation phasing statusFilter = bpy.context.scene.AddEditProperties.add() statusFilter.pset_name = "Pset_InstallationPhasing" statusFilter.property_name = "Status" statusFilter.string_value = "NEW" statusFilter.primary_measure_type = 'IfcGloballyUniqueId' statusFilter.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") phasingFilter = bpy.context.scene.AddEditProperties.add() phasingFilter.pset_name = "Pset_InstallationPhasing" phasingFilter.property_name = "Work description" phasingFilter.string_value = "Rock installation for second filter layer building" phasingFilter.primary_measure_type = 'IfcGloballyUniqueId' phasingFilter.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") phasingFilter = bpy.context.scene.AddEditProperties.add() phasingFilter.pset_name = "Pset_InstallationPhasing" phasingFilter.property_name = "Starting date" phasingFilter.string_value = "15/06/2024" phasingFilter.primary_measure_type = 'IfcGloballyUniqueId' phasingFilter.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") phasingFilter = bpy.context.scene.AddEditProperties.add() phasingFilter.pset_name = "Pset_InstallationPhasing" phasingFilter.property_name = "Ending date" phasingFilter.string_value = "15/07/2024" phasingFilter.primary_measure_type = 'IfcGloballyUniqueId' phasingFilter.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") phasingFilter = bpy.context.scene.AddEditProperties.add() phasingFilter.pset_name = "Pset_InstallationPhasing" phasingFilter.property_name = "Total work days" phasingFilter.string_value = "30" phasingFilter.primary_measure_type = 'IfcGloballyUniqueId' phasingFilter.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") # General data psetGenaralData = "GENERAL DATA" psetFilterCost = bpy.context.scene.AddEditProperties.add() psetFilterCost.pset_name = psetGenaralData psetFilterCost.property_name = "Manifacturing" psetFilterCost.string_value = "Natural rock extracted from quarries" psetFilterCost.primary_measure_type = 'IfcGloballyUniqueId' psetFilterCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") psetFilterCost = bpy.context.scene.AddEditProperties.add() psetFilterCost.pset_name = psetGenaralData psetFilterCost.property_name = "Material" psetFilterCost.string_value = "Natural rock" psetFilterCost.primary_measure_type = 'IfcGloballyUniqueId' psetFilterCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") psetFilterCost = bpy.context.scene.AddEditProperties.add() psetFilterCost.pset_name = psetGenaralData psetFilterCost.property_name = "Volume [m3]" psetFilterCost.string_value = str(VfilterLayer) psetFilterCost.primary_measure_type = 'IfcGloballyUniqueId' psetFilterCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/FilterLayer", obj_type="Object") if c.name.startswith("IfcCivilElement/UnderLayer"): # UNDER LAYER PROPERTIES # # Pset Installation phasing statusULayer = bpy.context.scene.AddEditProperties.add() statusULayer.pset_name = "Pset_InstallationPhasing" statusULayer.property_name = "Status" statusULayer.string_value = "NEW" statusULayer.primary_measure_type = 'IfcGloballyUniqueId' statusULayer.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") phasingULayer = bpy.context.scene.AddEditProperties.add() phasingULayer.pset_name = "Pset_InstallationPhasing" phasingULayer.property_name = "Work description" phasingULayer.string_value = "Rock installation for first layer buinlding" phasingULayer.primary_measure_type = 'IfcGloballyUniqueId' phasingULayer.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") phasingULayer = bpy.context.scene.AddEditProperties.add() phasingULayer.pset_name = "Pset_InstallationPhasing" phasingULayer.property_name = "Starting date" phasingULayer.string_value = "01/05/2024" phasingULayer.primary_measure_type = 'IfcGloballyUniqueId' phasingULayer.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") phasingULayer = bpy.context.scene.AddEditProperties.add() phasingULayer.pset_name = "Pset_InstallationPhasing" phasingULayer.property_name = "Ending date" phasingULayer.string_value = "31/05/2024" phasingULayer.primary_measure_type = 'IfcGloballyUniqueId' phasingULayer.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") phasingULayer = bpy.context.scene.AddEditProperties.add() phasingULayer.pset_name = "Pset_InstallationPhasing" phasingULayer.property_name = "Total work days" phasingULayer.string_value = "31" phasingULayer.primary_measure_type = 'IfcGloballyUniqueId' phasingULayer.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") # General data psetGenaralData = "GENERAL DATA" psetULayerCost = bpy.context.scene.AddEditProperties.add() psetULayerCost.pset_name = psetGenaralData psetULayerCost.property_name = "Manifacturing" psetULayerCost.string_value = "Natural rock extracted from quarries" psetULayerCost.primary_measure_type = 'IfcGloballyUniqueId' psetULayerCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") psetULayerCost = bpy.context.scene.AddEditProperties.add() psetULayerCost.pset_name = psetGenaralData psetULayerCost.property_name = "Material" psetULayerCost.string_value = "Natural rock" psetULayerCost.primary_measure_type = 'IfcGloballyUniqueId' psetULayerCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") psetULayerCost = bpy.context.scene.AddEditProperties.add() psetULayerCost.pset_name = psetGenaralData psetULayerCost.property_name = "Volume [m3]" psetULayerCost.string_value = str(UnderLayerVol) psetULayerCost.primary_measure_type = 'IfcGloballyUniqueId' psetULayerCost.template_type = 'IfcPropertySingleValue' bpy.ops.bim.add_edit_custom_property() bpy.ops.bim.disable_pset_editing(obj="IfcCivilElement/UnderLayer", obj_type="Object") saveIFC = True pathIFC = "D:\\DOTTORATO\\0000_WORK\\0010_BLENDER_BIM\\0000_WORK\\2024_02_06\\IFC\\model_4D.ifc" if saveIFC: bpy.ops.export_ifc.bim(filepath = pathIFC, should_save_as = False, save_as_invoked = True)