From c425b44ca94440d029c4a70ad0c09bae181ef8f9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 8 Nov 2019 16:45:39 +1100 Subject: [PATCH] Store generated GlobalId values for parametric geometry --- src/ifcblenderexport/io_export_ifc/__init__.py | 1 + src/ifcblenderexport/io_export_ifc/export_ifc.py | 12 +++++++++++- src/ifcblenderexport/io_export_ifc/ui.py | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/io_export_ifc/__init__.py b/src/ifcblenderexport/io_export_ifc/__init__.py index a070c26a55..1e4b1008f3 100644 --- a/src/ifcblenderexport/io_export_ifc/__init__.py +++ b/src/ifcblenderexport/io_export_ifc/__init__.py @@ -58,6 +58,7 @@ classes = ( ui.Pset, ui.Document, ui.Classification, + ui.GlobalId, ui.BIMObjectProperties, ui.BIMMaterialProperties, ui.BIMMeshProperties, diff --git a/src/ifcblenderexport/io_export_ifc/export_ifc.py b/src/ifcblenderexport/io_export_ifc/export_ifc.py index aaf2199c2d..b50ad279d8 100644 --- a/src/ifcblenderexport/io_export_ifc/export_ifc.py +++ b/src/ifcblenderexport/io_export_ifc/export_ifc.py @@ -212,16 +212,26 @@ class IfcParser(): def resolve_array_modifier(self, product): object = product['raw'] instance_objects = [(object, object.location)] + global_id_index = 0 for instance in self.get_instances(object): created_instances = [] for n in range(instance.count-1): for o in instance_objects: location = o[1] + ((n+1) * instance.offset) self.add_product(self.get_product({ 'raw': o[0], 'metadata': product['metadata'] }, - {'location': location}, {'GlobalId': ifcopenshell.guid.new()})) + {'location': location}, {'GlobalId': self.get_parametric_global_id(object, global_id_index)})) created_instances.append((o[0], location)) instance_objects.extend(created_instances) + def get_parametric_global_id(self, object, index): + global_ids = object.BIMObjectProperties.global_ids + total_global_ids = len(global_ids) + if index < total_global_ids: + return global_ids[index].name + global_id = object.BIMObjectProperties.global_ids.add() + global_id.name = ifcopenshell.guid.new() + return global_id.name + def add_product(self, product): self.products.append(product) self.product_name_index_map[product['raw'].name] = self.product_index diff --git a/src/ifcblenderexport/io_export_ifc/ui.py b/src/ifcblenderexport/io_export_ifc/ui.py index d67f6b3574..7441d36aab 100644 --- a/src/ifcblenderexport/io_export_ifc/ui.py +++ b/src/ifcblenderexport/io_export_ifc/ui.py @@ -112,6 +112,9 @@ class Classification(bpy.types.PropertyGroup): name: bpy.props.StringProperty(name="Name") identification: bpy.props.StringProperty(name="Identification") +class GlobalId(bpy.types.PropertyGroup): + name: bpy.props.StringProperty(name="Name") + class BIMObjectProperties(bpy.types.PropertyGroup): def getApplicableAttributes(self, context): if '/' in bpy.context.active_object.name \ @@ -129,6 +132,7 @@ class BIMObjectProperties(bpy.types.PropertyGroup): results.append((uri, uri, '')) return results + global_ids: bpy.props.CollectionProperty(name="GlobalIds", type=GlobalId) attributes: bpy.props.CollectionProperty(name="Attributes", type=Attribute) psets: bpy.props.CollectionProperty(name="Psets", type=Pset) applicable_attributes: bpy.props.EnumProperty(items=getApplicableAttributes, name="Attribute Names")