Add support for importing IFC groups

This commit is contained in:
Dion Moult
2020-04-15 10:08:09 +10:00
parent 66afa9872d
commit 7adf4934aa
5 changed files with 1055 additions and 3 deletions
@@ -198,6 +198,7 @@ class IfcImporter():
self.unit_scale = 1
self.added_data = {}
self.native_data = {}
self.groups = {}
self.material_creator = MaterialCreator(ifc_import_settings)
@@ -218,6 +219,7 @@ class IfcImporter():
self.parse_native_products()
self.filter_ifc()
self.patch_ifc()
self.create_groups()
self.create_type_products()
self.create_grids()
# TODO: Deprecate after bug #682 is fixed and the new importer is stable
@@ -365,6 +367,18 @@ class IfcImporter():
if element.ObjectPlacement.RelativePlacement.RefDirection:
element.ObjectPlacement.RelativePlacement.RefDirection.DirectionRatios = (1., 0., 0.)
def create_groups(self):
collection = bpy.data.collections.new('Groups')
self.project['blender'].children.link(collection)
for element in self.file.by_type('IfcGroup'):
obj = bpy.data.objects.new(f'IfcGroup/{element.Name}', None)
self.add_element_attributes(element, obj)
collection.objects.link(obj)
self.groups[element.GlobalId] = {
'ifc': element,
'blender': obj
}
def create_grids(self):
grids = self.file.by_type('IfcGrid')
for grid in grids:
+1 -1
View File
@@ -122,7 +122,7 @@ def getIfcProducts(self, context):
global products_enum
if len(products_enum) < 1:
products_enum.extend([(e, e, '') for e in
['IfcElement', 'IfcElementType', 'IfcSpatialElement', 'IfcStructural', 'IfcContext']])
['IfcElement', 'IfcElementType', 'IfcSpatialElement', 'IfcGroup', 'IfcStructural', 'IfcContext']])
return products_enum
@@ -13,6 +13,7 @@ class IfcSchema():
'IfcContext',
'IfcElement',
'IfcSpatialElement',
'IfcGroup',
'IfcStructural',
'IfcMaterialDefinition',
'IfcParameterizedProfileDef',
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -41,9 +41,11 @@ class IFC4Extractor:
def is_descendant_from_class(self, element, class_name):
if element is None \
or "substitutionGroup" not in element.attrib:
or 'substitutionGroup' not in element.attrib \
or 'type' not in element.attrib:
return False
if element.attrib["substitutionGroup"] == 'ifc:{}'.format(class_name):
if element.attrib['substitutionGroup'] == 'ifc:{}'.format(class_name) \
or element.attrib['type'] == 'ifc:{}'.format(class_name):
return True
return self.is_descendant_from_class(self.get_parent_element(element), class_name)
@@ -149,6 +151,7 @@ filename_filters = {
'IfcContext_IFC4.json': ['IfcContext'],
'IfcElement_IFC4.json': ['IfcElement'],
'IfcSpatialElement_IFC4.json': ['IfcSpatialElement'],
'IfcGroup_IFC4.json': ['IfcGroup'],
'IfcStructural_IFC4.json': ['IfcStructuralActivity', 'IfcStructuralItem'],
'IfcMaterialDefinition_IFC4.json': ['IfcMaterialDefinition'],
'IfcParameterizedProfileDef_IFC4.json': ['IfcParameterizedProfileDef'],