mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 03:37:21 +00:00
Assigning a representation to a product type now syncs mapped representations of all of its typed products.
This commit is contained in:
@@ -72,7 +72,9 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
|
|
||||||
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
bpy.ops.bim.edit_object_placement(obj=obj.name)
|
||||||
|
|
||||||
if obj.data:
|
if not obj.data:
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
product = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
|
|
||||||
context_id = self.context_id or int(bpy.context.scene.BIMProperties.contexts)
|
context_id = self.context_id or int(bpy.context.scene.BIMProperties.contexts)
|
||||||
@@ -105,6 +107,7 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
print("Failed to write shape representation")
|
print("Failed to write shape representation")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
# TODO: Migrate to parametric engine system
|
||||||
box_context_id = get_context_id("Model", "Box", "MODEL_VIEW")
|
box_context_id = get_context_id("Model", "Box", "MODEL_VIEW")
|
||||||
old_box = ifcopenshell.util.representation.get_representation(product, "Model", "Box", "MODEL_VIEW")
|
old_box = ifcopenshell.util.representation.get_representation(product, "Model", "Box", "MODEL_VIEW")
|
||||||
if (
|
if (
|
||||||
@@ -150,6 +153,14 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
mesh.BIMMeshProperties.ifc_definition_id = int(result.id())
|
mesh.BIMMeshProperties.ifc_definition_id = int(result.id())
|
||||||
obj.data = mesh
|
obj.data = mesh
|
||||||
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
|
Data.load(IfcStore.get_file(), obj.BIMObjectProperties.ifc_definition_id)
|
||||||
|
|
||||||
|
if self.file.schema == "IFC2X3":
|
||||||
|
types = product.ObjectTypeOf
|
||||||
|
else:
|
||||||
|
types = product.Types
|
||||||
|
if product.is_a("IfcTypeProduct") and types:
|
||||||
|
for element in types[0].RelatedObjects:
|
||||||
|
Data.load(IfcStore.get_file(), element.id())
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,4 +35,18 @@ class Usecase:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.settings["product"].RepresentationMaps = maps
|
self.settings["product"].RepresentationMaps = maps
|
||||||
|
if self.file.schema == "IFC2X3":
|
||||||
|
types = self.settings["product"].ObjectTypeOf
|
||||||
|
else:
|
||||||
|
types = self.settings["product"].Types
|
||||||
|
if types:
|
||||||
|
for element in types[0].RelatedObjects:
|
||||||
|
mapped_representation = ifcopenshell.api.run(
|
||||||
|
"geometry.map_representation", self.file, **{"representation": self.settings["representation"]}
|
||||||
|
)
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"geometry.assign_representation",
|
||||||
|
self.file,
|
||||||
|
**{"product": element, "representation": mapped_representation}
|
||||||
|
)
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": self.settings["product"]})
|
||||||
|
|||||||
Reference in New Issue
Block a user