Fix issues adding roof and railing representation #5534

Apparently after recent changes with how types are added, it's now required to add a representation for them explicitly instead of just marking them as edited
This commit is contained in:
Andrej730
2024-10-04 12:29:47 +05:00
parent 69781daa6b
commit 3107fd91ee
4 changed files with 25 additions and 24 deletions
@@ -353,7 +353,7 @@ class AddRailing(bpy.types.Operator, tool.Ifc.Operator):
refresh()
update_railing_modifier_bmesh(context)
update_railing_modifier_ifc_data(context)
return {"FINISHED"}
tool.Model.add_body_representation(obj)
class EnableEditingRailing(bpy.types.Operator, tool.Ifc.Operator):
+1 -1
View File
@@ -580,7 +580,7 @@ class AddRoof(bpy.types.Operator, tool.Ifc.Operator):
refresh()
update_roof_modifier_bmesh(context)
update_roof_modifier_ifc_data(context)
return {"FINISHED"}
tool.Model.add_body_representation(obj)
class EnableEditingRoof(bpy.types.Operator, tool.Ifc.Operator):
+2 -22
View File
@@ -65,26 +65,6 @@ def regenerate_stair_mesh(context):
obj.data.update()
def update_stair_representation(obj):
body = ifcopenshell.util.representation.get_context(tool.Ifc.get(), "Model", "Body", "MODEL_VIEW")
representation = ifcopenshell.api.run(
"geometry.add_representation",
tool.Ifc.get(),
context=body,
blender_object=obj,
geometry=obj.data,
coordinate_offset=tool.Geometry.get_cartesian_point_offset(obj),
total_items=tool.Geometry.get_total_representation_items(obj),
should_force_faceted_brep=tool.Geometry.should_force_faceted_brep(),
should_force_triangulation=tool.Geometry.should_force_triangulation(),
should_generate_uvs=tool.Geometry.should_generate_uvs(obj),
ifc_representation_class=None,
profile_set_usage=None,
)
tool.Model.replace_object_ifc_representation(body, obj, representation)
tool.Ifc.finish_edit(obj)
def update_ifc_stair_props(obj):
"""should be called after new geometry settled
since it's going to update ifc representation
@@ -220,7 +200,7 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator):
)
regenerate_stair_mesh(context)
update_ifc_stair_props(obj)
update_stair_representation(obj)
tool.Model.add_body_representation(obj)
class CancelEditingStair(bpy.types.Operator, tool.Ifc.Operator):
@@ -255,7 +235,7 @@ class FinishEditingStair(bpy.types.Operator, tool.Ifc.Operator):
data = props.get_props_kwargs(convert_to_project_units=True)
props.is_editing = False
regenerate_stair_mesh(context)
update_stair_representation(obj)
tool.Model.add_body_representation(obj)
pset = tool.Pset.get_element_pset(element, "BBIM_Stair")
data = tool.Ifc.get().createIfcText(json.dumps(data))
+21
View File
@@ -1405,3 +1405,24 @@ class Model(bonsai.core.tool.Model):
mesh.materials.pop(index=i1)
else:
mesh.materials[i1] = mbstyle2
@classmethod
def add_body_representation(cls, obj: bpy.types.Object) -> None:
ifc_file = tool.Ifc.get()
body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
representation = ifcopenshell.api.run(
"geometry.add_representation",
ifc_file,
context=body,
blender_object=obj,
geometry=obj.data,
coordinate_offset=tool.Geometry.get_cartesian_point_offset(obj),
total_items=tool.Geometry.get_total_representation_items(obj),
should_force_faceted_brep=tool.Geometry.should_force_faceted_brep(),
should_force_triangulation=tool.Geometry.should_force_triangulation(),
should_generate_uvs=tool.Geometry.should_generate_uvs(obj),
ifc_representation_class=None,
profile_set_usage=None,
)
tool.Model.replace_object_ifc_representation(body, obj, representation)
tool.Ifc.finish_edit(obj)