mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Move pset definitions into a property group and create a UI for it
This commit is contained in:
@@ -32,6 +32,8 @@ classes = (
|
|||||||
operator.AssignSweptSolidProfile,
|
operator.AssignSweptSolidProfile,
|
||||||
operator.AssignSweptSolidExtrusion,
|
operator.AssignSweptSolidExtrusion,
|
||||||
operator.AssignPset,
|
operator.AssignPset,
|
||||||
|
operator.UnassignPset,
|
||||||
|
operator.AddPset,
|
||||||
operator.RemovePset,
|
operator.RemovePset,
|
||||||
operator.GenerateGlobalId,
|
operator.GenerateGlobalId,
|
||||||
operator.AddAttribute,
|
operator.AddAttribute,
|
||||||
@@ -39,6 +41,7 @@ classes = (
|
|||||||
operator.QuickProjectSetup,
|
operator.QuickProjectSetup,
|
||||||
ui.BIMProperties,
|
ui.BIMProperties,
|
||||||
ui.Attribute,
|
ui.Attribute,
|
||||||
|
ui.Pset,
|
||||||
ui.ObjectProperties,
|
ui.ObjectProperties,
|
||||||
ui.MaterialProperties,
|
ui.MaterialProperties,
|
||||||
ui.MeshProperties,
|
ui.MeshProperties,
|
||||||
|
|||||||
@@ -271,11 +271,12 @@ class IfcParser():
|
|||||||
if object.name in self.qtos:
|
if object.name in self.qtos:
|
||||||
self.rel_defines_by_qto.setdefault(object.name, []).append(product)
|
self.rel_defines_by_qto.setdefault(object.name, []).append(product)
|
||||||
|
|
||||||
|
for pset in object.ObjectProperties.psets:
|
||||||
|
self.rel_defines_by_pset.setdefault(
|
||||||
|
'{}/{}'.format(pset.name, pset.file), []).append(product)
|
||||||
|
|
||||||
for key in object.keys():
|
for key in object.keys():
|
||||||
if key[0:5] == 'Pset_':
|
if key[0:3] == 'Doc':
|
||||||
self.rel_defines_by_pset.setdefault(
|
|
||||||
'{}/{}'.format(key, object[key]), []).append(product)
|
|
||||||
elif key[0:3] == 'Doc':
|
|
||||||
self.rel_associates_document_object.setdefault(
|
self.rel_associates_document_object.setdefault(
|
||||||
object[key], []).append(product)
|
object[key], []).append(product)
|
||||||
elif key[0:5] == 'Class':
|
elif key[0:5] == 'Class':
|
||||||
@@ -651,8 +652,8 @@ class IfcParser():
|
|||||||
'location': object.location,
|
'location': object.location,
|
||||||
'up_axis': object.matrix_world.to_quaternion() @ Vector((0, 0, 1)),
|
'up_axis': object.matrix_world.to_quaternion() @ Vector((0, 0, 1)),
|
||||||
'forward_axis': object.matrix_world.to_quaternion() @ Vector((1, 0, 0)),
|
'forward_axis': object.matrix_world.to_quaternion() @ Vector((1, 0, 0)),
|
||||||
'psets': ['{}/{}'.format(key, object[key]) for key in
|
'psets': ['{}/{}'.format(pset.name, pset.file) for pset in
|
||||||
object.keys() if key[0:5] == 'Pset_'],
|
object.ObjectProperties.psets],
|
||||||
'class': self.get_ifc_class(object.name),
|
'class': self.get_ifc_class(object.name),
|
||||||
'representations': self.get_object_representation_names(object),
|
'representations': self.get_object_representation_names(object),
|
||||||
'attributes': self.get_object_attributes(object)
|
'attributes': self.get_object_attributes(object)
|
||||||
|
|||||||
@@ -228,17 +228,42 @@ class AssignPset(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for object in bpy.context.selected_objects:
|
for object in bpy.context.selected_objects:
|
||||||
object[bpy.context.scene.BIMProperties.pset_name] = bpy.context.scene.BIMProperties.pset_file
|
index = object.ObjectProperties.psets.find(bpy.context.scene.BIMProperties.pset_name)
|
||||||
|
if index >= 0:
|
||||||
|
global_id = object.ObjectProperties.psets[index]
|
||||||
|
else:
|
||||||
|
global_id = object.ObjectProperties.psets.add()
|
||||||
|
global_id.name = bpy.context.scene.BIMProperties.pset_name
|
||||||
|
global_id.file = bpy.context.scene.BIMProperties.pset_file
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class UnassignPset(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.unassign_pset'
|
||||||
|
bl_label = 'Unassign Pset'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
for object in bpy.context.selected_objects:
|
||||||
|
index = object.ObjectProperties.psets.find(bpy.context.scene.BIMProperties.pset_name)
|
||||||
|
if index != -1:
|
||||||
|
object.ObjectProperties.psets.remove(index)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class AddPset(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.add_pset'
|
||||||
|
bl_label = 'Add Pset'
|
||||||
|
|
||||||
|
# This is a temporary measure until we get a better UI
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.context.active_object.ObjectProperties.psets.add()
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class RemovePset(bpy.types.Operator):
|
class RemovePset(bpy.types.Operator):
|
||||||
bl_idname = 'bim.remove_pset'
|
bl_idname = 'bim.remove_pset'
|
||||||
bl_label = 'Remove Pset'
|
bl_label = 'Remove Pset'
|
||||||
|
pset_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for object in bpy.context.selected_objects:
|
bpy.context.active_object.ObjectProperties.psets.remove(self.pset_index)
|
||||||
if bpy.context.scene.BIMProperties.pset_name in object.keys():
|
|
||||||
del(object[bpy.context.scene.BIMProperties.pset_name])
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class GenerateGlobalId(bpy.types.Operator):
|
class GenerateGlobalId(bpy.types.Operator):
|
||||||
@@ -246,12 +271,10 @@ class GenerateGlobalId(bpy.types.Operator):
|
|||||||
bl_label = 'Generate GlobalId'
|
bl_label = 'Generate GlobalId'
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
global_id = None
|
index = bpy.context.active_object.ObjectProperties.attributes.find('GlobalId')
|
||||||
for attribute in bpy.context.active_object.ObjectProperties.attributes:
|
if index >= 0:
|
||||||
if attribute.name == 'GlobalId':
|
global_id = bpy.context.active_object.ObjectProperties.attributes[index]
|
||||||
global_id = attribute
|
else:
|
||||||
break
|
|
||||||
if not global_id:
|
|
||||||
global_id = bpy.context.active_object.ObjectProperties.attributes.add()
|
global_id = bpy.context.active_object.ObjectProperties.attributes.add()
|
||||||
global_id.name = 'GlobalId'
|
global_id.name = 'GlobalId'
|
||||||
global_id.data_type = 'string'
|
global_id.data_type = 'string'
|
||||||
|
|||||||
@@ -55,8 +55,13 @@ class Attribute(bpy.types.PropertyGroup):
|
|||||||
int_value: bpy.props.IntProperty(name="Value")
|
int_value: bpy.props.IntProperty(name="Value")
|
||||||
float_value: bpy.props.FloatProperty(name="Value")
|
float_value: bpy.props.FloatProperty(name="Value")
|
||||||
|
|
||||||
|
class Pset(bpy.types.PropertyGroup):
|
||||||
|
name: bpy.props.StringProperty(name="Name")
|
||||||
|
file: bpy.props.StringProperty(name="File")
|
||||||
|
|
||||||
class ObjectProperties(bpy.types.PropertyGroup):
|
class ObjectProperties(bpy.types.PropertyGroup):
|
||||||
attributes: bpy.props.CollectionProperty(name="Attributes", type=Attribute)
|
attributes: bpy.props.CollectionProperty(name="Attributes", type=Attribute)
|
||||||
|
psets: bpy.props.CollectionProperty(name="Psets", type=Pset)
|
||||||
|
|
||||||
class MaterialProperties(bpy.types.PropertyGroup):
|
class MaterialProperties(bpy.types.PropertyGroup):
|
||||||
is_external: bpy.props.BoolProperty(name="Has External Definition")
|
is_external: bpy.props.BoolProperty(name="Has External Definition")
|
||||||
@@ -96,6 +101,19 @@ class ObjectPanel(bpy.types.Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(bpy.context.active_object.ObjectProperties, 'attributes')
|
row.prop(bpy.context.active_object.ObjectProperties, 'attributes')
|
||||||
|
|
||||||
|
layout.label(text="Property Sets:")
|
||||||
|
row = layout.row()
|
||||||
|
row.operator('bim.add_pset')
|
||||||
|
|
||||||
|
for index, pset in enumerate(bpy.context.active_object.ObjectProperties.psets):
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(pset, 'name', text='')
|
||||||
|
row.prop(pset, 'file', text='')
|
||||||
|
row.operator('bim.remove_pset', icon='CANCEL', text='').pset_index = index
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(bpy.context.active_object.ObjectProperties, 'psets')
|
||||||
|
|
||||||
class MeshPanel(bpy.types.Panel):
|
class MeshPanel(bpy.types.Panel):
|
||||||
bl_label = 'IFC Representations'
|
bl_label = 'IFC Representations'
|
||||||
bl_idname = 'BIM_PT_mesh'
|
bl_idname = 'BIM_PT_mesh'
|
||||||
@@ -187,7 +205,7 @@ class BIMPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.operator("bim.assign_pset")
|
row.operator("bim.assign_pset")
|
||||||
row.operator("bim.remove_pset")
|
row.operator("bim.unassign_pset")
|
||||||
|
|
||||||
layout.label(text="Quality Auditing:")
|
layout.label(text="Quality Auditing:")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user