mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-05 20:06:25 +00:00
125 lines
4.1 KiB
Python
125 lines
4.1 KiB
Python
import bpy
|
|
|
|
|
|
class OpenPieClass(bpy.types.Operator):
|
|
bl_idname = "bim.open_pie_class"
|
|
bl_label = "Open Pie Class"
|
|
|
|
def execute(self, context):
|
|
bpy.ops.wm.call_menu_pie(name="VIEW3D_MT_PIE_bim_class")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class AssignIfcWall(bpy.types.Operator):
|
|
bl_idname = "bim.assign_ifc_wall"
|
|
bl_label = "IfcWall"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcWall")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class AssignIfcSlab(bpy.types.Operator):
|
|
bl_idname = "bim.assign_ifc_slab"
|
|
bl_label = "IfcSlab"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcSlab")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class AssignIfcStair(bpy.types.Operator):
|
|
bl_idname = "bim.assign_ifc_stair"
|
|
bl_label = "IfcStair"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcStair")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class AssignIfcDoor(bpy.types.Operator):
|
|
bl_idname = "bim.assign_ifc_door"
|
|
bl_label = "IfcDoor"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcDoor")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class AssignIfcWindow(bpy.types.Operator):
|
|
bl_idname = "bim.assign_ifc_window"
|
|
bl_label = "IfcWindow"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcWindow")
|
|
return {"FINISHED"}
|
|
|
|
|
|
class PieAddOpening(bpy.types.Operator):
|
|
bl_idname = "bim.pie_add_opening"
|
|
bl_label = "Add Opening"
|
|
|
|
def execute(self, context):
|
|
if len(context.selected_objects) == 2:
|
|
opening_name = None
|
|
obj_name = None
|
|
for obj in context.selected_objects:
|
|
if "IfcOpeningElement" in obj.name or not obj.BIMObjectProperties.ifc_definition_id:
|
|
opening_name = obj.name
|
|
else:
|
|
opj_name = obj.name
|
|
bpy.ops.bim.add_opening(obj=opj_name, opening=opening_name)
|
|
return {"FINISHED"}
|
|
|
|
|
|
class PieUpdateContainer(bpy.types.Operator):
|
|
bl_idname = "bim.pie_update_container"
|
|
bl_label = "Update Spatial Container"
|
|
|
|
def execute(self, context):
|
|
for obj in context.selected_objects:
|
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
|
continue
|
|
relating_structure = None
|
|
for collection in obj.users_collection:
|
|
relating_structure_obj = bpy.data.objects.get(collection.name)
|
|
if not relating_structure_obj or not relating_structure_obj.BIMObjectProperties.ifc_definition_id:
|
|
continue
|
|
relating_structure = relating_structure_obj
|
|
bpy.ops.bim.assign_container(relating_structure=relating_structure.name, related_element=obj.name)
|
|
return {"FINISHED"}
|
|
|
|
|
|
class VIEW3D_MT_PIE_bim(bpy.types.Menu):
|
|
bl_label = "Geometry"
|
|
|
|
def draw(self, context):
|
|
pie = self.layout.menu_pie()
|
|
pie.operator("bim.edit_object_placement")
|
|
pie.operator("bim.update_mesh_representation")
|
|
pie.operator("bim.pie_add_opening")
|
|
pie.operator("bim.pie_update_container")
|
|
pie.operator("bim.open_pie_class", text="Assign IFC Class")
|
|
|
|
|
|
class VIEW3D_MT_PIE_bim_class(bpy.types.Menu):
|
|
bl_label = "IFC Class"
|
|
|
|
def draw(self, context):
|
|
pie = self.layout.menu_pie()
|
|
pie.operator("bim.assign_ifc_wall")
|
|
pie.operator("bim.assign_ifc_slab")
|
|
pie.operator("bim.assign_ifc_stair")
|
|
pie.operator("bim.assign_ifc_door")
|
|
pie.operator("bim.assign_ifc_window")
|