diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index e52d3ec08b..c6aded9647 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -21,6 +21,7 @@ if bpy is not None: from .module.model import opening as model_opening classes = ( + operator.ReassignClass, operator.AssignClass, operator.UnassignClass, operator.SelectClass, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 943bf0d5f3..0355a5fddf 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -214,6 +214,20 @@ class SelectPset(bpy.types.Operator): return {"FINISHED"} +class ReassignClass(bpy.types.Operator): + bl_idname = "bim.reassign_class" + bl_label = "Reassign IFC Class" + + def execute(self, context): + obj = bpy.context.active_object + bpy.context.active_object.BIMObjectProperties.is_reassigning_class = True + bpy.context.scene.BIMProperties.ifc_class = obj.name.split("/")[0] + predefined_type = obj.BIMObjectProperties.attributes.get("PredefinedType") + if predefined_type: + bpy.context.scene.BIMProperties.ifc_predefined_type = predefined_type.string_value + return {"FINISHED"} + + class AssignClass(bpy.types.Operator): bl_idname = "bim.assign_class" bl_label = "Assign IFC Class" @@ -222,6 +236,7 @@ class AssignClass(bpy.types.Operator): def execute(self, context): if self.object_name: objects = [bpy.data.objects.get(self.object_name)] + objects[0].BIMObjectProperties.is_reassigning_class = False else: objects = bpy.context.selected_objects for obj in objects: diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 99d12d58d5..0be6873209 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1589,6 +1589,7 @@ class BoundaryCondition(PropertyGroup): class BIMObjectProperties(PropertyGroup): + is_reassigning_class: BoolProperty(name="Is Reassigning Class") global_ids: CollectionProperty(name="GlobalIds", type=GlobalId) attributes: CollectionProperty(name="Attributes", type=Attribute) relating_type: PointerProperty(name="Type Product", type=bpy.types.Object) diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index b92cae0513..4077b84ae0 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -21,24 +21,28 @@ class BIM_PT_object(Panel): props = context.active_object.BIMObjectProperties bim_properties = context.scene.BIMProperties - row = layout.row() - row.prop(bim_properties, "ifc_product") - row = layout.row() - row.prop(bim_properties, "ifc_class") - if bim_properties.ifc_predefined_type: + if props.is_reassigning_class or "/" not in context.active_object.name: row = layout.row() - row.prop(bim_properties, "ifc_predefined_type") - if bim_properties.ifc_predefined_type == "USERDEFINED": + row.prop(bim_properties, "ifc_product") row = layout.row() - row.prop(bim_properties, "ifc_userdefined_type") - row = layout.row(align=True) - if "Ifc" not in context.active_object.name: - op = row.operator("bim.assign_class") + row.prop(bim_properties, "ifc_class") + if bim_properties.ifc_predefined_type: + row = layout.row() + row.prop(bim_properties, "ifc_predefined_type") + if bim_properties.ifc_predefined_type == "USERDEFINED": + row = layout.row() + row.prop(bim_properties, "ifc_userdefined_type") + row = layout.row(align=True) + if "Ifc" not in context.active_object.name: + op = row.operator("bim.assign_class") + else: + op = row.operator("bim.assign_class") + op.object_name = context.active_object.name + op = row.operator("bim.unassign_class", icon="X", text="") + op.object_name = context.active_object.name else: - op = row.operator("bim.assign_class", text="Reassign IFC Class") - op.object_name = context.active_object.name - op = row.operator("bim.unassign_class", icon="X", text="") - op.object_name = context.active_object.name + row = layout.row() + row.operator("bim.reassign_class", text="Reassign IFC Class") if "Ifc" not in context.active_object.name: return @@ -1892,7 +1896,10 @@ class BIM_UL_classifications(bpy.types.UIList): class BIM_ADDON_preferences(bpy.types.AddonPreferences): bl_idname = "blenderbim" svg2pdf_command: StringProperty(name="SVG to PDF Command", description="E.g. [['inkscape', svg, '-o', pdf]]") - svg2dxf_command: StringProperty(name="SVG to DXF Command", description="E.g. [['inkscape', svg, '-o', eps], ['pstoedit', '-dt', '-f', 'dxf:-polyaslines -mm', eps, dxf, '-psarg', '-dNOSAFER']]") + svg2dxf_command: StringProperty( + name="SVG to DXF Command", + description="E.g. [['inkscape', svg, '-o', eps], ['pstoedit', '-dt', '-f', 'dxf:-polyaslines -mm', eps, dxf, '-psarg', '-dNOSAFER']]", + ) svg_command: StringProperty(name="SVG Command", description="E.g. [['firefox-bin', path]]") pdf_command: StringProperty(name="PDF Command", description="E.g. [['firefox-bin', path]]")