Fix #946. More intuitive UI for reassigning IFC class of the active object.

This commit is contained in:
Dion Moult
2020-11-03 22:59:35 +11:00
parent ad1cc7f0b9
commit b07d999bce
4 changed files with 40 additions and 16 deletions
@@ -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,
@@ -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:
@@ -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)
+23 -16
View File
@@ -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]]")