2021-01-04 13:07:29 +11:00
|
|
|
import bpy
|
|
|
|
|
from bpy.types import Panel
|
2021-03-25 10:48:31 +11:00
|
|
|
from ifcopenshell.api.root.data import Data
|
2021-01-05 21:15:52 +11:00
|
|
|
from blenderbim.bim.ifc import IfcStore
|
2021-01-04 13:07:29 +11:00
|
|
|
|
2021-01-12 15:12:53 +11:00
|
|
|
|
2021-01-04 13:07:29 +11:00
|
|
|
class BIM_PT_class(Panel):
|
|
|
|
|
bl_label = "IFC Class"
|
|
|
|
|
bl_idname = "BIM_PT_class"
|
|
|
|
|
bl_space_type = "PROPERTIES"
|
|
|
|
|
bl_region_type = "WINDOW"
|
|
|
|
|
bl_context = "object"
|
|
|
|
|
|
2021-01-05 21:15:52 +11:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
return IfcStore.get_file()
|
|
|
|
|
|
2021-01-04 13:07:29 +11:00
|
|
|
def draw(self, context):
|
|
|
|
|
props = context.active_object.BIMObjectProperties
|
|
|
|
|
if props.ifc_definition_id:
|
|
|
|
|
if props.ifc_definition_id not in Data.products:
|
2021-03-09 12:50:50 +11:00
|
|
|
try:
|
2021-03-25 10:48:31 +11:00
|
|
|
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
2021-03-09 12:50:50 +11:00
|
|
|
except:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text="IFC Element Not Found")
|
|
|
|
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
2021-06-15 13:05:24 +10:00
|
|
|
return
|
2021-01-04 13:07:29 +11:00
|
|
|
if props.is_reassigning_class:
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.operator("bim.reassign_class", icon="CHECKMARK")
|
|
|
|
|
row.operator("bim.disable_reassign_class", icon="X", text="")
|
2021-07-29 23:08:17 +02:00
|
|
|
self.draw_class_dropdowns(context)
|
2021-01-04 13:07:29 +11:00
|
|
|
else:
|
|
|
|
|
data = Data.products[props.ifc_definition_id]
|
|
|
|
|
name = data["type"]
|
|
|
|
|
if data["PredefinedType"] and data["PredefinedType"] == "USERDEFINED":
|
|
|
|
|
name += "[{}]".format(data["ObjectType"])
|
|
|
|
|
elif data["PredefinedType"]:
|
|
|
|
|
name += "[{}]".format(data["PredefinedType"])
|
|
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
row.label(text=name)
|
2021-07-19 19:19:12 +10:00
|
|
|
row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF").ifc_class = data["type"]
|
2021-04-18 20:24:08 +10:00
|
|
|
row.operator("bim.copy_class", icon="DUPLICATE", text="")
|
2021-03-09 12:50:50 +11:00
|
|
|
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
2021-04-22 14:00:18 +10:00
|
|
|
if IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcRoot"):
|
|
|
|
|
row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="")
|
2021-03-13 09:58:12 +11:00
|
|
|
if context.selected_objects:
|
|
|
|
|
row.operator("bim.unassign_class", icon="X", text="")
|
|
|
|
|
else:
|
|
|
|
|
row.operator("bim.unassign_class", icon="X", text="").obj = context.active_object.name
|
2021-01-04 13:07:29 +11:00
|
|
|
else:
|
2021-07-29 23:08:17 +02:00
|
|
|
self.draw_class_dropdowns(context)
|
2021-01-04 13:07:29 +11:00
|
|
|
row = self.layout.row(align=True)
|
|
|
|
|
op = row.operator("bim.assign_class")
|
2021-07-29 23:08:17 +02:00
|
|
|
op.ifc_class = context.scene.BIMRootProperties.ifc_class
|
|
|
|
|
op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type
|
|
|
|
|
op.userdefined_type = context.scene.BIMRootProperties.ifc_userdefined_type
|
2021-01-04 13:07:29 +11:00
|
|
|
|
2021-07-29 23:08:17 +02:00
|
|
|
def draw_class_dropdowns(self, context):
|
|
|
|
|
props = context.scene.BIMRootProperties
|
2021-01-04 13:07:29 +11:00
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "ifc_product")
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "ifc_class")
|
|
|
|
|
if props.ifc_predefined_type:
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "ifc_predefined_type")
|
|
|
|
|
if props.ifc_predefined_type == "USERDEFINED":
|
|
|
|
|
row = self.layout.row()
|
|
|
|
|
row.prop(props, "ifc_userdefined_type")
|
2021-03-10 21:10:00 +11:00
|
|
|
row = self.layout.row()
|
2021-07-29 23:08:17 +02:00
|
|
|
row.prop(context.scene.BIMProperties, "contexts")
|