mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
New feature to unassign/reassign IFC class easily
This commit is contained in:
@@ -13,6 +13,7 @@ if bpy is not None:
|
||||
|
||||
classes = (
|
||||
operator.AssignClass,
|
||||
operator.UnassignClass,
|
||||
operator.SelectClass,
|
||||
operator.SelectType,
|
||||
operator.SelectBcfFile,
|
||||
|
||||
@@ -174,7 +174,7 @@ class AssignClass(bpy.types.Operator):
|
||||
for obj in objects:
|
||||
existing_class = None
|
||||
if '/' in obj.name \
|
||||
and obj.name[0:3] == 'Ifc':
|
||||
and obj.name[0:3] == 'Ifc':
|
||||
existing_class = obj.name.split('/')[0]
|
||||
if existing_class:
|
||||
obj.name = '{}/{}'.format(
|
||||
@@ -200,6 +200,25 @@ class AssignClass(bpy.types.Operator):
|
||||
object_type.string_value = bpy.context.scene.BIMProperties.ifc_userdefined_type
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class UnassignClass(bpy.types.Operator):
|
||||
bl_idname = 'bim.unassign_class'
|
||||
bl_label = 'Unassign IFC Class'
|
||||
object_name: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
if self.object_name:
|
||||
objects = [bpy.data.objects.get(self.object_name)]
|
||||
else:
|
||||
objects = bpy.context.selected_objects
|
||||
for obj in objects:
|
||||
existing_class = None
|
||||
if '/' in obj.name \
|
||||
and obj.name[0:3] == 'Ifc':
|
||||
obj.name = '/'.join(obj.name.split('/')[1:])
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SelectClass(bpy.types.Operator):
|
||||
bl_idname = 'bim.select_class'
|
||||
bl_label = 'Select IFC Class'
|
||||
|
||||
@@ -20,20 +20,26 @@ 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:
|
||||
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:
|
||||
row = layout.row()
|
||||
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.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()
|
||||
op = row.operator("bim.assign_class")
|
||||
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
|
||||
|
||||
if 'Ifc' not in context.active_object.name:
|
||||
return
|
||||
|
||||
layout.label(text="Software Identity:")
|
||||
@@ -845,9 +851,11 @@ class BIM_PT_bim(Panel):
|
||||
if bim_properties.ifc_predefined_type == 'USERDEFINED':
|
||||
row = layout.row()
|
||||
row.prop(bim_properties, "ifc_userdefined_type")
|
||||
row = layout.row()
|
||||
row = layout.row(align=True)
|
||||
op = row.operator("bim.assign_class")
|
||||
op.object_name = ''
|
||||
op = row.operator("bim.unassign_class", icon='X', text='')
|
||||
op.object_name = ''
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.select_class")
|
||||
|
||||
Reference in New Issue
Block a user