up
This commit is contained in:
parent
68e61445a2
commit
d19fa0044a
2 changed files with 27 additions and 11 deletions
|
|
@ -39,15 +39,23 @@ def get_referenced_objects(node, visited=None):
|
|||
return objs
|
||||
|
||||
_is_updating = False
|
||||
|
||||
@persistent
|
||||
def depsgraph_update_handler(scene, depsgraph):
|
||||
global _is_updating
|
||||
if _is_updating:
|
||||
return
|
||||
|
||||
updated_objects = {update.id.name for update in depsgraph.updates if isinstance(update.id, bpy.types.Object)}
|
||||
if not updated_objects:
|
||||
# Names of objects that have changed
|
||||
updated_object_names = {update.id.name for update in depsgraph.updates if isinstance(update.id, bpy.types.Object)}
|
||||
|
||||
# Also check for mesh updates (happens in Edit Mode)
|
||||
updated_meshes = {update.id.name for update in depsgraph.updates if isinstance(update.id, bpy.types.Mesh)}
|
||||
if updated_meshes:
|
||||
for obj in bpy.data.objects:
|
||||
if obj.type == 'MESH' and obj.data in updated_meshes:
|
||||
updated_object_names.add(obj.name)
|
||||
|
||||
if not updated_object_names:
|
||||
return
|
||||
|
||||
for tree in bpy.data.node_groups:
|
||||
|
|
@ -57,7 +65,8 @@ def depsgraph_update_handler(scene, depsgraph):
|
|||
for node in tree.nodes:
|
||||
if node.bl_idname == "SLICENODE_Executor" and getattr(node, "auto_refresh", False):
|
||||
referenced = get_referenced_objects(node)
|
||||
if any(obj.name in updated_objects for obj in referenced):
|
||||
referenced_names = {obj.name for obj in referenced if obj}
|
||||
if updated_object_names & referenced_names:
|
||||
_is_updating = True
|
||||
try:
|
||||
node.evaluate()
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class SlicingObject():
|
|||
scene_scale: float = bpy.context.scene.unit_settings.scale_length
|
||||
|
||||
if obj:
|
||||
if obj.mode == 'EDIT':
|
||||
obj.update_from_editmode()
|
||||
eval_objects = obj.evaluated_get(depsgraph)
|
||||
self.mesh = objects_to_tris([eval_objects], 1000 * scene_scale)
|
||||
else:
|
||||
|
|
@ -219,6 +221,8 @@ class SlicingGroup():
|
|||
|
||||
self.wipe_tower_xy = self.center_xy[0:2]
|
||||
for obj in objs:
|
||||
if obj.mode == 'EDIT':
|
||||
obj.update_from_editmode()
|
||||
eval_obj = obj.evaluated_get(depsgraph)
|
||||
if eval_obj.blendertoprusaslicer.object_type == 'WipeTower':
|
||||
self.wipe_tower_xy = np.array(eval_obj.location[0:2]) * scale_tx
|
||||
|
|
@ -414,6 +418,9 @@ def _cached_capture_mesh_edges(
|
|||
def capture_mesh_edges(obj: Object) -> list[NDArray[float64]]:
|
||||
if not obj or not obj.data: return []
|
||||
|
||||
if obj.mode == 'EDIT':
|
||||
obj.update_from_editmode()
|
||||
|
||||
assert bpy.context.scene and bpy.context.scene.unit_settings
|
||||
scene_scale = 1000.0 * bpy.context.scene.unit_settings.scale_length
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue