Users are prompted to assign an IFC class prior to changing IFC metadata. See #869.

This commit is contained in:
Dion Moult
2020-06-04 10:47:51 +10:00
parent 12bb14da48
commit d0f02f9247
2 changed files with 36 additions and 14 deletions
+19 -14
View File
@@ -164,33 +164,38 @@ class SelectPset(bpy.types.Operator):
class AssignClass(bpy.types.Operator):
bl_idname = 'bim.assign_class'
bl_label = 'Assign IFC Class'
object_name: bpy.props.StringProperty()
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
if '/' in object.name \
and object.name[0:3] == 'Ifc':
existing_class = object.name.split('/')[0]
if '/' in obj.name \
and obj.name[0:3] == 'Ifc':
existing_class = obj.name.split('/')[0]
if existing_class:
object.name = '{}/{}'.format(
obj.name = '{}/{}'.format(
bpy.context.scene.BIMProperties.ifc_class,
object.name.split('/')[1])
obj.name.split('/')[1])
else:
object.name = '{}/{}'.format(
obj.name = '{}/{}'.format(
bpy.context.scene.BIMProperties.ifc_class,
object.name)
predefined_type_index = object.BIMObjectProperties.attributes.find('PredefinedType')
obj.name)
predefined_type_index = obj.BIMObjectProperties.attributes.find('PredefinedType')
if predefined_type_index >= 0:
object.BIMObjectProperties.attributes.remove(predefined_type_index)
object_type_index = object.BIMObjectProperties.attributes.find('ObjectType')
obj.BIMObjectProperties.attributes.remove(predefined_type_index)
object_type_index = obj.BIMObjectProperties.attributes.find('ObjectType')
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:
predefined_type = object.BIMObjectProperties.attributes.add()
predefined_type = obj.BIMObjectProperties.attributes.add()
predefined_type.name = 'PredefinedType'
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':
object_type = object.BIMObjectProperties.attributes.add()
object_type = obj.BIMObjectProperties.attributes.add()
object_type.name = 'ObjectType'
object_type.string_value = bpy.context.scene.BIMProperties.ifc_userdefined_type
return {'FINISHED'}
+17
View File
@@ -18,6 +18,23 @@ class BIM_PT_object(Panel):
return
layout = self.layout
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:")
row = layout.row()