Remove triangulation on switch_representation

Now all walls, beams etc should become be displayed with quads.
This commit is contained in:
Andrej730
2023-08-09 15:47:17 +05:00
parent f8ffc97bf5
commit 6913864850
2 changed files with 15 additions and 0 deletions
@@ -115,6 +115,7 @@ def switch_representation(
geometry.change_object_data(obj, data, is_global=is_global) geometry.change_object_data(obj, data, is_global=is_global)
geometry.record_object_materials(obj) geometry.record_object_materials(obj)
geometry.remove_triangulation(obj)
if should_reload and existing_data: if should_reload and existing_data:
geometry.delete_data(existing_data) geometry.delete_data(existing_data)
@@ -31,6 +31,7 @@ import blenderbim.bim.import_ifc
from math import radians from math import radians
from mathutils import Vector from mathutils import Vector
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from math import radians
class Geometry(blenderbim.core.tool.Geometry): class Geometry(blenderbim.core.tool.Geometry):
@@ -545,6 +546,19 @@ class Geometry(blenderbim.core.tool.Geometry):
def rename_object(cls, obj, name): def rename_object(cls, obj, name):
obj.name = name obj.name = name
@classmethod
def remove_triangulation(cls, obj):
"""
Convert triangles to quads without bpy.ops.
Note that it uses bmesh based on object mesh.
"""
mesh = obj.data
bm = tool.Blender.get_bmesh_for_mesh(mesh)
# angle values come from defaults for `bpy.ops.mesh.tris_convert_to_quads()``
bmesh.ops.join_triangles(bm, faces=bm.faces[:], angle_face_threshold=radians(40), angle_shape_threshold=radians(40))
bm.normal_update()
tool.Blender.apply_bmesh(mesh, bm, obj)
@classmethod @classmethod
def replace_object_with_empty(cls, obj): def replace_object_with_empty(cls, obj):
element = tool.Ifc.get_entity(obj) element = tool.Ifc.get_entity(obj)