Skip to content

Commit 6913864

Browse files
committed
Remove triangulation on switch_representation
Now all walls, beams etc should become be displayed with quads.
1 parent f8ffc97 commit 6913864

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/blenderbim/blenderbim/core/geometry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def switch_representation(
115115

116116
geometry.change_object_data(obj, data, is_global=is_global)
117117
geometry.record_object_materials(obj)
118+
geometry.remove_triangulation(obj)
118119

119120
if should_reload and existing_data:
120121
geometry.delete_data(existing_data)

src/blenderbim/blenderbim/tool/geometry.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from math import radians
3232
from mathutils import Vector
3333
from blenderbim.bim.ifc import IfcStore
34+
from math import radians
3435

3536

3637
class Geometry(blenderbim.core.tool.Geometry):
@@ -545,6 +546,19 @@ def remove_connection(cls, connection):
545546
def rename_object(cls, obj, name):
546547
obj.name = name
547548

549+
@classmethod
550+
def remove_triangulation(cls, obj):
551+
"""
552+
Convert triangles to quads without bpy.ops.
553+
Note that it uses bmesh based on object mesh.
554+
"""
555+
mesh = obj.data
556+
bm = tool.Blender.get_bmesh_for_mesh(mesh)
557+
# angle values come from defaults for `bpy.ops.mesh.tris_convert_to_quads()``
558+
bmesh.ops.join_triangles(bm, faces=bm.faces[:], angle_face_threshold=radians(40), angle_shape_threshold=radians(40))
559+
bm.normal_update()
560+
tool.Blender.apply_bmesh(mesh, bm, obj)
561+
548562
@classmethod
549563
def replace_object_with_empty(cls, obj):
550564
element = tool.Ifc.get_entity(obj)

0 commit comments

Comments
 (0)