import numpy import os import bpy # ==================================== folderOut = r"D:\DOTTORATO\0000_WORK\0010_BLENDER_BIM\0000_WORK\2024_04_05\DXF" fileOut = "model_planView.dxf" # ==================================== building_collection = bpy.data.collections["IfcBuilding/My Building"].objects storey_collection = bpy.data.collections["IfcBuildingStorey/My Storey"].objects # ==================================== for obj in building_collection: if obj.name.startswith("IfcCivilElement/Core"): bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert(target="CURVE") bpy.ops.bim.add_representation() if obj.name.startswith("IfcCivilElement/UnderLayer"): bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert(target="CURVE") bpy.ops.bim.add_representation() if obj.name.startswith("IfcCivilElement/BermDX"): bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert(target="CURVE") bpy.ops.bim.add_representation() if obj.name.startswith("IfcCivilElement/BermSX"): bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert(target="CURVE") bpy.ops.bim.add_representation() if obj.name.startswith("IfcCivilElement/FilterLayer"): bpy.ops.object.select_all(action='DESELECT') obj.select_set(True) bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert(target="CURVE") bpy.ops.bim.add_representation() for obj in storey_collection: if obj.name.startswith("IfcCivilElement/AccropodeFinal"): bpy.context.view_layer.objects.active = obj obj.BIMGeometryProperties.contexts = "29" bpy.ops.object.convert bpy.ops.bim.add_representation() bpy.ops.object.select_all(action = "SELECT") saveDXF = False if saveDXF: fileContents = os.path.join(folderOut, fileOut) bpy.ops.export.dxf(filepath = fileContents) bpy.ops.object.select_all(action = "DESELECT")