mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 19:56:20 +00:00
Fix #1435. Fix bug where box reps could be duplicated upon adding a new body, and ensure all styles are created prior to adding new body geometry.
This commit is contained in:
@@ -104,18 +104,27 @@ class AddRepresentation(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
box_context_id = get_context_id("Model", "Box", "MODEL_VIEW")
|
box_context_id = get_context_id("Model", "Box", "MODEL_VIEW")
|
||||||
|
old_box = ifcopenshell.util.element.get_representation(product, "Model", "Box", "MODEL_VIEW")
|
||||||
if (
|
if (
|
||||||
box_context_id
|
box_context_id
|
||||||
and context_of_items.ContextType == "Model"
|
and context_of_items.ContextType == "Model"
|
||||||
and context_of_items.ContextIdentifier
|
and context_of_items.ContextIdentifier
|
||||||
and context_of_items.ContextIdentifier == "Body"
|
and context_of_items.ContextIdentifier == "Body"
|
||||||
):
|
):
|
||||||
|
if old_box:
|
||||||
|
bpy.ops.bim.remove_representation(representation_id=old_box.id(), obj=obj.name)
|
||||||
representation_data["context"] = self.file.by_id(box_context_id)
|
representation_data["context"] = self.file.by_id(box_context_id)
|
||||||
new_box = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
|
new_box = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", self.file, **{"product": product, "representation": new_box}
|
"geometry.assign_representation", self.file, **{"product": product, "representation": new_box}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
[
|
||||||
|
bpy.ops.bim.add_style(material=s.material.name)
|
||||||
|
for s in obj.material_slots
|
||||||
|
if not s.material.BIMMaterialProperties.ifc_style_id
|
||||||
|
]
|
||||||
|
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_styles",
|
"geometry.assign_styles",
|
||||||
self.file,
|
self.file,
|
||||||
|
|||||||
Reference in New Issue
Block a user