mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
Fixed issue with tool.Blender.apply_bmesh
This commit is contained in:
@@ -102,7 +102,7 @@ class Annotator:
|
|||||||
new_verts = [bm.verts.new(v) for v in verts_local]
|
new_verts = [bm.verts.new(v) for v in verts_local]
|
||||||
|
|
||||||
bm.faces.new([new_verts[i] for i in face_verts])
|
bm.faces.new([new_verts[i] for i in face_verts])
|
||||||
tool.Blender.apply_bmesh(obj.data, bm)
|
tool.Blender.apply_bmesh(obj.data, bm, obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Blender:
|
|||||||
def update_viewport(cls): pass
|
def update_viewport(cls): pass
|
||||||
def get_default_selection_keypmap(cls): pass
|
def get_default_selection_keypmap(cls): pass
|
||||||
def get_object_bounding_box(cls, obj): pass
|
def get_object_bounding_box(cls, obj): pass
|
||||||
def apply_bmesh(cls, mesh, bm): pass
|
def apply_bmesh(cls, mesh, bm, obj=None): pass
|
||||||
def get_bmesh_for_mesh(cls, mesh, clean=False): pass
|
def get_bmesh_for_mesh(cls, mesh, clean=False): pass
|
||||||
def bmesh_join(cls, bm_a, bm_b, callback=None): pass
|
def bmesh_join(cls, bm_a, bm_b, callback=None): pass
|
||||||
|
|
||||||
|
|||||||
@@ -180,10 +180,12 @@ class Blender:
|
|||||||
|
|
||||||
## BMESH UTILS ##
|
## BMESH UTILS ##
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_bmesh(cls, mesh, bm):
|
def apply_bmesh(cls, mesh, bm, obj=None):
|
||||||
|
"""`obj` argument is not optional if you plan to update mesh in EDIT mode
|
||||||
|
and it's possible that that mesh object won't be currenly active."""
|
||||||
import bmesh
|
import bmesh
|
||||||
|
|
||||||
if bpy.context.object and bpy.context.object.mode == "EDIT":
|
if mesh.is_editmode:
|
||||||
# better to be safe because otherwise mesh won't be updated
|
# better to be safe because otherwise mesh won't be updated
|
||||||
# and you won't get any errors
|
# and you won't get any errors
|
||||||
if not bm.is_wrapped or hash(bmesh.from_edit_mesh(mesh)) != hash(bm):
|
if not bm.is_wrapped or hash(bmesh.from_edit_mesh(mesh)) != hash(bm):
|
||||||
@@ -192,7 +194,13 @@ class Blender:
|
|||||||
"For applying bmesh in edit mode bmesh should be acquired with `bmesh.from_edit_mesh(me)`."
|
"For applying bmesh in edit mode bmesh should be acquired with `bmesh.from_edit_mesh(me)`."
|
||||||
)
|
)
|
||||||
bmesh.update_edit_mesh(mesh)
|
bmesh.update_edit_mesh(mesh)
|
||||||
bpy.context.object.update_from_editmode()
|
if not obj:
|
||||||
|
if not bpy.context.object and bpy.context.object.data != mesh:
|
||||||
|
raise Exception(
|
||||||
|
"Error applying bmesh in EDIT object - object is "
|
||||||
|
"not provided and can't be acquired from the context. "
|
||||||
|
)
|
||||||
|
obj.update_from_editmode()
|
||||||
else:
|
else:
|
||||||
bm.to_mesh(mesh)
|
bm.to_mesh(mesh)
|
||||||
# only freeing bmesh if object is in OBJECT mode
|
# only freeing bmesh if object is in OBJECT mode
|
||||||
|
|||||||
Reference in New Issue
Block a user