mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Allow qtos to be imported
This commit is contained in:
@@ -66,6 +66,7 @@ if bpy is not None:
|
|||||||
operator.RemovePset,
|
operator.RemovePset,
|
||||||
operator.AddOverridePset,
|
operator.AddOverridePset,
|
||||||
operator.RemoveOverridePset,
|
operator.RemoveOverridePset,
|
||||||
|
operator.RemoveQto,
|
||||||
operator.AddMaterialPset,
|
operator.AddMaterialPset,
|
||||||
operator.RemoveMaterialPset,
|
operator.RemoveMaterialPset,
|
||||||
operator.AddDocument,
|
operator.AddDocument,
|
||||||
@@ -107,7 +108,7 @@ if bpy is not None:
|
|||||||
prop.TargetCRS,
|
prop.TargetCRS,
|
||||||
prop.Attribute,
|
prop.Attribute,
|
||||||
prop.BoundaryCondition,
|
prop.BoundaryCondition,
|
||||||
prop.Pset,
|
prop.PsetQto,
|
||||||
prop.Document,
|
prop.Document,
|
||||||
prop.Classification,
|
prop.Classification,
|
||||||
prop.GlobalId,
|
prop.GlobalId,
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ class IfcImporter():
|
|||||||
self.add_element_attributes(element, obj)
|
self.add_element_attributes(element, obj)
|
||||||
self.add_element_document_relations(element, obj)
|
self.add_element_document_relations(element, obj)
|
||||||
self.add_defines_by_type_relation(element, obj)
|
self.add_defines_by_type_relation(element, obj)
|
||||||
self.add_product_psets(element, obj)
|
self.add_product_definitions(element, obj)
|
||||||
self.added_data[element.GlobalId] = obj
|
self.added_data[element.GlobalId] = obj
|
||||||
|
|
||||||
def merge_by_class(self):
|
def merge_by_class(self):
|
||||||
@@ -379,14 +379,16 @@ class IfcImporter():
|
|||||||
bpy.ops.mesh.normals_make_consistent(context_override)
|
bpy.ops.mesh.normals_make_consistent(context_override)
|
||||||
bpy.ops.object.editmode_toggle(context_override)
|
bpy.ops.object.editmode_toggle(context_override)
|
||||||
|
|
||||||
def add_product_psets(self, element, obj):
|
def add_product_definitions(self, element, obj):
|
||||||
if not hasattr(element, 'IsDefinedBy') or not element.IsDefinedBy:
|
if not hasattr(element, 'IsDefinedBy') or not element.IsDefinedBy:
|
||||||
return
|
return
|
||||||
for definition in element.IsDefinedBy:
|
for definition in element.IsDefinedBy:
|
||||||
if not definition.is_a('IfcRelDefinesByProperties') \
|
if not definition.is_a('IfcRelDefinesByProperties'):
|
||||||
or not definition.RelatingPropertyDefinition.is_a('IfcPropertySet'):
|
|
||||||
continue
|
continue
|
||||||
self.add_pset(definition.RelatingPropertyDefinition, obj)
|
if definition.RelatingPropertyDefinition.is_a('IfcPropertySet'):
|
||||||
|
self.add_pset(definition.RelatingPropertyDefinition, obj)
|
||||||
|
elif definition.RelatingPropertyDefinition.is_a('IfcElementQuantity'):
|
||||||
|
self.add_qto(definition.RelatingPropertyDefinition, obj)
|
||||||
|
|
||||||
def add_type_product_psets(self, element, obj):
|
def add_type_product_psets(self, element, obj):
|
||||||
if not hasattr(element, 'HasPropertySets') or not element.HasPropertySets:
|
if not hasattr(element, 'HasPropertySets') or not element.HasPropertySets:
|
||||||
@@ -396,21 +398,41 @@ class IfcImporter():
|
|||||||
self.add_pset(definition, obj)
|
self.add_pset(definition, obj)
|
||||||
|
|
||||||
def add_pset(self, pset, obj):
|
def add_pset(self, pset, obj):
|
||||||
new_pset = obj.BIMObjectProperties.override_psets.add()
|
new_pset = obj.BIMObjectProperties.override_psets.add()
|
||||||
new_pset.name = pset.Name
|
new_pset.name = pset.Name
|
||||||
if new_pset.name in schema.ifc.psets:
|
if new_pset.name in schema.ifc.psets:
|
||||||
for prop_name in schema.ifc.psets[new_pset.name]['HasPropertyTemplates'].keys():
|
for prop_name in schema.ifc.psets[new_pset.name]['HasPropertyTemplates'].keys():
|
||||||
prop = new_pset.properties.add()
|
prop = new_pset.properties.add()
|
||||||
prop.name = prop_name
|
prop.name = prop_name
|
||||||
for prop in pset.HasProperties:
|
for prop in pset.HasProperties:
|
||||||
if prop.is_a('IfcPropertySingleValue') and prop.NominalValue:
|
if prop.is_a('IfcPropertySingleValue') and prop.NominalValue:
|
||||||
index = new_pset.properties.find(prop.Name)
|
index = new_pset.properties.find(prop.Name)
|
||||||
if index >= 0:
|
if index >= 0:
|
||||||
new_pset.properties[index].string_value = str(prop.NominalValue.wrappedValue)
|
new_pset.properties[index].string_value = str(prop.NominalValue.wrappedValue)
|
||||||
else:
|
else:
|
||||||
new_prop = new_pset.properties.add()
|
new_prop = new_pset.properties.add()
|
||||||
new_prop.name = prop.Name
|
new_prop.name = prop.Name
|
||||||
new_prop.string_value = str(prop.NominalValue.wrappedValue)
|
new_prop.string_value = str(prop.NominalValue.wrappedValue)
|
||||||
|
|
||||||
|
def add_qto(self, qto, obj):
|
||||||
|
new_qto = obj.BIMObjectProperties.qtos.add()
|
||||||
|
new_qto.name = qto.Name
|
||||||
|
if new_qto.name in schema.ifc.qtos:
|
||||||
|
for prop_name in schema.ifc.qtos[new_qto.name]['HasPropertyTemplates'].keys():
|
||||||
|
prop = new_qto.properties.add()
|
||||||
|
prop.name = prop_name
|
||||||
|
for prop in qto.Quantities:
|
||||||
|
if prop.is_a('IfcPhysicalSimpleQuantity'):
|
||||||
|
value = getattr(prop, '{}Value'.format(prop.is_a()[len('IfcQuantity'):]))
|
||||||
|
if not value:
|
||||||
|
continue
|
||||||
|
index = new_qto.properties.find(prop.Name)
|
||||||
|
if index >= 0:
|
||||||
|
new_qto.properties[index].string_value = str(value)
|
||||||
|
else:
|
||||||
|
new_prop = new_qto.properties.add()
|
||||||
|
new_prop.name = prop.Name
|
||||||
|
new_prop.string_value = str(value)
|
||||||
|
|
||||||
def add_defines_by_type_relation(self, element, obj):
|
def add_defines_by_type_relation(self, element, obj):
|
||||||
related_type = None
|
related_type = None
|
||||||
|
|||||||
@@ -506,6 +506,16 @@ class RemoveOverridePset(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class RemoveQto(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.remove_qto'
|
||||||
|
bl_label = 'Remove Qto'
|
||||||
|
index: bpy.props.IntProperty()
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
bpy.context.active_object.BIMObjectProperties.qtos.remove(self.index)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class AddMaterialPset(bpy.types.Operator):
|
class AddMaterialPset(bpy.types.Operator):
|
||||||
bl_idname = 'bim.add_material_pset'
|
bl_idname = 'bim.add_material_pset'
|
||||||
bl_label = 'Add Material Pset'
|
bl_label = 'Add Material Pset'
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ class Attribute(PropertyGroup):
|
|||||||
int_value: IntProperty(name="Value")
|
int_value: IntProperty(name="Value")
|
||||||
float_value: FloatProperty(name="Value")
|
float_value: FloatProperty(name="Value")
|
||||||
|
|
||||||
class Pset(PropertyGroup):
|
class PsetQto(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
file: StringProperty(name="File")
|
file: StringProperty(name="File")
|
||||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||||
@@ -481,13 +481,14 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
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)
|
||||||
relating_structure: PointerProperty(name='Spatial Container', type=bpy.types.Object)
|
relating_structure: PointerProperty(name='Spatial Container', type=bpy.types.Object)
|
||||||
psets: CollectionProperty(name="Psets", type=Pset)
|
psets: CollectionProperty(name="Psets", type=PsetQto)
|
||||||
|
qtos: CollectionProperty(name="Qtos", type=PsetQto)
|
||||||
applicable_attributes: EnumProperty(items=getApplicableAttributes, name="Attribute Names")
|
applicable_attributes: EnumProperty(items=getApplicableAttributes, name="Attribute Names")
|
||||||
documents: CollectionProperty(name="Documents", type=Document)
|
documents: CollectionProperty(name="Documents", type=Document)
|
||||||
applicable_documents: EnumProperty(items=getApplicableDocuments, name="Available Documents")
|
applicable_documents: EnumProperty(items=getApplicableDocuments, name="Available Documents")
|
||||||
classifications: CollectionProperty(name="Classifications", type=Classification)
|
classifications: CollectionProperty(name="Classifications", type=Classification)
|
||||||
material_type: EnumProperty(items=getMaterialTypes, name="Material Type")
|
material_type: EnumProperty(items=getMaterialTypes, name="Material Type")
|
||||||
override_psets: CollectionProperty(name="Override Psets", type=Pset)
|
override_psets: CollectionProperty(name="Override Psets", type=PsetQto)
|
||||||
override_pset_name: StringProperty(name="Override Pset Name")
|
override_pset_name: StringProperty(name="Override Pset Name")
|
||||||
has_boundary_condition: BoolProperty(name='Has Boundary Condition')
|
has_boundary_condition: BoolProperty(name='Has Boundary Condition')
|
||||||
boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition)
|
boundary_condition: PointerProperty(name='Boundary Condition', type=BoundaryCondition)
|
||||||
@@ -500,7 +501,7 @@ class BIMMaterialProperties(PropertyGroup):
|
|||||||
identification: StringProperty(name="Identification")
|
identification: StringProperty(name="Identification")
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
available_material_psets: EnumProperty(items=getAvailableMaterialPsets, name="Material Pset")
|
available_material_psets: EnumProperty(items=getAvailableMaterialPsets, name="Material Pset")
|
||||||
psets: CollectionProperty(name="Psets", type=Pset)
|
psets: CollectionProperty(name="Psets", type=PsetQto)
|
||||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||||
applicable_attributes: EnumProperty(items=getApplicableMaterialAttributes, name="Attribute Names")
|
applicable_attributes: EnumProperty(items=getApplicableMaterialAttributes, name="Attribute Names")
|
||||||
profile_def: EnumProperty(items=getProfileDef, name='Parameterized Profile Def', update=refreshProfileAttributes)
|
profile_def: EnumProperty(items=getProfileDef, name='Parameterized Profile Def', update=refreshProfileAttributes)
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ class IfcSchema():
|
|||||||
self.type_map = json.load(f)
|
self.type_map = json.load(f)
|
||||||
|
|
||||||
for property_file in self.property_files:
|
for property_file in self.property_files:
|
||||||
for property in property_file.by_type('IfcPropertySetTemplate'):
|
for prop in property_file.by_type('IfcPropertySetTemplate'):
|
||||||
if property.Name[0:4] == 'Qto_':
|
if prop.Name[0:4] == 'Qto_':
|
||||||
# self.qtos.append({ })
|
self.qtos[prop.Name] = {
|
||||||
pass
|
'HasPropertyTemplates': {p.Name: p for p in prop.HasPropertyTemplates}}
|
||||||
else:
|
else:
|
||||||
self.psets[property.Name] = {
|
self.psets[prop.Name] = {
|
||||||
'HasPropertyTemplates': {p.Name: p for p in property.HasPropertyTemplates}}
|
'HasPropertyTemplates': {p.Name: p for p in prop.HasPropertyTemplates}}
|
||||||
|
|
||||||
ifc = IfcSchema()
|
ifc = IfcSchema()
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ class BIM_PT_object(Panel):
|
|||||||
row.prop(prop, 'name', text='')
|
row.prop(prop, 'name', text='')
|
||||||
row.prop(prop, 'string_value', text='')
|
row.prop(prop, 'string_value', text='')
|
||||||
|
|
||||||
|
layout.label(text="Quantities:")
|
||||||
|
|
||||||
|
for index, qto in enumerate(props.qtos):
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(qto, 'name', text='')
|
||||||
|
row.operator('bim.remove_qto', icon='X', text='').index = index
|
||||||
|
for prop in qto.properties:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(prop, 'name', text='')
|
||||||
|
row.prop(prop, 'string_value', text='')
|
||||||
|
|
||||||
layout.label(text="Documents:")
|
layout.label(text="Documents:")
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, 'applicable_documents', text='')
|
row.prop(props, 'applicable_documents', text='')
|
||||||
|
|||||||
Reference in New Issue
Block a user