mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-01 20:49:44 +00:00
Fix #946. More intuitive UI for reassigning IFC class of the active object.
This commit is contained in:
@@ -21,6 +21,7 @@ if bpy is not None:
|
|||||||
from .module.model import opening as model_opening
|
from .module.model import opening as model_opening
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
operator.ReassignClass,
|
||||||
operator.AssignClass,
|
operator.AssignClass,
|
||||||
operator.UnassignClass,
|
operator.UnassignClass,
|
||||||
operator.SelectClass,
|
operator.SelectClass,
|
||||||
|
|||||||
@@ -214,6 +214,20 @@ class SelectPset(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class AssignClass(bpy.types.Operator):
|
||||||
bl_idname = "bim.assign_class"
|
bl_idname = "bim.assign_class"
|
||||||
bl_label = "Assign IFC Class"
|
bl_label = "Assign IFC Class"
|
||||||
@@ -222,6 +236,7 @@ class AssignClass(bpy.types.Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
if self.object_name:
|
if self.object_name:
|
||||||
objects = [bpy.data.objects.get(self.object_name)]
|
objects = [bpy.data.objects.get(self.object_name)]
|
||||||
|
objects[0].BIMObjectProperties.is_reassigning_class = False
|
||||||
else:
|
else:
|
||||||
objects = bpy.context.selected_objects
|
objects = bpy.context.selected_objects
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
|
|||||||
@@ -1589,6 +1589,7 @@ class BoundaryCondition(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class BIMObjectProperties(PropertyGroup):
|
class BIMObjectProperties(PropertyGroup):
|
||||||
|
is_reassigning_class: BoolProperty(name="Is Reassigning Class")
|
||||||
global_ids: CollectionProperty(name="GlobalIds", type=GlobalId)
|
global_ids: CollectionProperty(name="GlobalIds", type=GlobalId)
|
||||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||||
relating_type: PointerProperty(name="Type Product", type=bpy.types.Object)
|
relating_type: PointerProperty(name="Type Product", type=bpy.types.Object)
|
||||||
|
|||||||
@@ -21,24 +21,28 @@ class BIM_PT_object(Panel):
|
|||||||
props = context.active_object.BIMObjectProperties
|
props = context.active_object.BIMObjectProperties
|
||||||
bim_properties = context.scene.BIMProperties
|
bim_properties = context.scene.BIMProperties
|
||||||
|
|
||||||
row = layout.row()
|
if props.is_reassigning_class or "/" not in context.active_object.name:
|
||||||
row.prop(bim_properties, "ifc_product")
|
|
||||||
row = layout.row()
|
|
||||||
row.prop(bim_properties, "ifc_class")
|
|
||||||
if bim_properties.ifc_predefined_type:
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bim_properties, "ifc_predefined_type")
|
row.prop(bim_properties, "ifc_product")
|
||||||
if bim_properties.ifc_predefined_type == "USERDEFINED":
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bim_properties, "ifc_userdefined_type")
|
row.prop(bim_properties, "ifc_class")
|
||||||
row = layout.row(align=True)
|
if bim_properties.ifc_predefined_type:
|
||||||
if "Ifc" not in context.active_object.name:
|
row = layout.row()
|
||||||
op = row.operator("bim.assign_class")
|
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:
|
else:
|
||||||
op = row.operator("bim.assign_class", text="Reassign IFC Class")
|
row = layout.row()
|
||||||
op.object_name = context.active_object.name
|
row.operator("bim.reassign_class", text="Reassign IFC Class")
|
||||||
op = row.operator("bim.unassign_class", icon="X", text="")
|
|
||||||
op.object_name = context.active_object.name
|
|
||||||
|
|
||||||
if "Ifc" not in context.active_object.name:
|
if "Ifc" not in context.active_object.name:
|
||||||
return
|
return
|
||||||
@@ -1892,7 +1896,10 @@ class BIM_UL_classifications(bpy.types.UIList):
|
|||||||
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||||
bl_idname = "blenderbim"
|
bl_idname = "blenderbim"
|
||||||
svg2pdf_command: StringProperty(name="SVG to PDF Command", description="E.g. [['inkscape', svg, '-o', pdf]]")
|
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]]")
|
svg_command: StringProperty(name="SVG Command", description="E.g. [['firefox-bin', path]]")
|
||||||
pdf_command: StringProperty(name="PDF Command", description="E.g. [['firefox-bin', path]]")
|
pdf_command: StringProperty(name="PDF Command", description="E.g. [['firefox-bin', path]]")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user