Store generated GlobalId values for parametric geometry

This commit is contained in:
Dion Moult
2019-11-08 16:45:39 +11:00
parent af16e64fd9
commit c425b44ca9
3 changed files with 16 additions and 1 deletions
@@ -58,6 +58,7 @@ classes = (
ui.Pset,
ui.Document,
ui.Classification,
ui.GlobalId,
ui.BIMObjectProperties,
ui.BIMMaterialProperties,
ui.BIMMeshProperties,
@@ -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
+4
View File
@@ -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")