mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 11:46:33 +00:00
Users are prompted to assign an IFC class prior to changing IFC metadata. See #869.
This commit is contained in:
@@ -164,33 +164,38 @@ class SelectPset(bpy.types.Operator):
|
|||||||
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'
|
||||||
|
object_name: bpy.props.StringProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for object in bpy.context.selected_objects:
|
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
|
existing_class = None
|
||||||
if '/' in object.name \
|
if '/' in obj.name \
|
||||||
and object.name[0:3] == 'Ifc':
|
and obj.name[0:3] == 'Ifc':
|
||||||
existing_class = object.name.split('/')[0]
|
existing_class = obj.name.split('/')[0]
|
||||||
if existing_class:
|
if existing_class:
|
||||||
object.name = '{}/{}'.format(
|
obj.name = '{}/{}'.format(
|
||||||
bpy.context.scene.BIMProperties.ifc_class,
|
bpy.context.scene.BIMProperties.ifc_class,
|
||||||
object.name.split('/')[1])
|
obj.name.split('/')[1])
|
||||||
else:
|
else:
|
||||||
object.name = '{}/{}'.format(
|
obj.name = '{}/{}'.format(
|
||||||
bpy.context.scene.BIMProperties.ifc_class,
|
bpy.context.scene.BIMProperties.ifc_class,
|
||||||
object.name)
|
obj.name)
|
||||||
predefined_type_index = object.BIMObjectProperties.attributes.find('PredefinedType')
|
predefined_type_index = obj.BIMObjectProperties.attributes.find('PredefinedType')
|
||||||
if predefined_type_index >= 0:
|
if predefined_type_index >= 0:
|
||||||
object.BIMObjectProperties.attributes.remove(predefined_type_index)
|
obj.BIMObjectProperties.attributes.remove(predefined_type_index)
|
||||||
object_type_index = object.BIMObjectProperties.attributes.find('ObjectType')
|
object_type_index = obj.BIMObjectProperties.attributes.find('ObjectType')
|
||||||
if object_type_index >= 0:
|
if object_type_index >= 0:
|
||||||
object.BIMObjectProperties.attributes.remove(object_type_index)
|
obj.BIMObjectProperties.attributes.remove(object_type_index)
|
||||||
if bpy.context.scene.BIMProperties.ifc_predefined_type:
|
if bpy.context.scene.BIMProperties.ifc_predefined_type:
|
||||||
predefined_type = object.BIMObjectProperties.attributes.add()
|
predefined_type = obj.BIMObjectProperties.attributes.add()
|
||||||
predefined_type.name = 'PredefinedType'
|
predefined_type.name = 'PredefinedType'
|
||||||
predefined_type.string_value = bpy.context.scene.BIMProperties.ifc_predefined_type # TODO: make it an enum
|
predefined_type.string_value = bpy.context.scene.BIMProperties.ifc_predefined_type # TODO: make it an enum
|
||||||
if bpy.context.scene.BIMProperties.ifc_predefined_type == 'USERDEFINED':
|
if bpy.context.scene.BIMProperties.ifc_predefined_type == 'USERDEFINED':
|
||||||
object_type = object.BIMObjectProperties.attributes.add()
|
object_type = obj.BIMObjectProperties.attributes.add()
|
||||||
object_type.name = 'ObjectType'
|
object_type.name = 'ObjectType'
|
||||||
object_type.string_value = bpy.context.scene.BIMProperties.ifc_userdefined_type
|
object_type.string_value = bpy.context.scene.BIMProperties.ifc_userdefined_type
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -18,6 +18,23 @@ class BIM_PT_object(Panel):
|
|||||||
return
|
return
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
props = context.active_object.BIMObjectProperties
|
props = context.active_object.BIMObjectProperties
|
||||||
|
bim_properties = context.scene.BIMProperties
|
||||||
|
|
||||||
|
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
|
||||||
|
return
|
||||||
|
|
||||||
layout.label(text="Software Identity:")
|
layout.label(text="Software Identity:")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user