Added automatic workflow centering when loading workflows from JSON files.
This commit is contained in:
parent
17f3be4c47
commit
9d3ef80f57
@ -97,7 +97,7 @@ def save_workflow(graph: NodeGraph):
|
||||
def load_workflow(graph: NodeGraph):
|
||||
"""
|
||||
Loads a workflow (including node values, connections, positions, etc.)
|
||||
from a specified JSON file.
|
||||
from a specified JSON file, and then centers the view on all loaded nodes.
|
||||
"""
|
||||
ensure_workflows_folder()
|
||||
file_filter = "JSON Files (*.json);;All Files (*.*)"
|
||||
@ -108,11 +108,16 @@ def load_workflow(graph: NodeGraph):
|
||||
|
||||
try:
|
||||
graph.load_session(file_path)
|
||||
|
||||
# After loading, center the viewer on all nodes.
|
||||
all_nodes = graph.all_nodes()
|
||||
if all_nodes:
|
||||
graph.viewer().zoom_to_nodes([node.view for node in all_nodes])
|
||||
|
||||
print(f"Workflow loaded from {file_path}")
|
||||
except Exception as e:
|
||||
QtWidgets.QMessageBox.critical(None, "Error Loading Workflow", str(e))
|
||||
|
||||
|
||||
def import_nodes_from_folder(package_name):
|
||||
"""
|
||||
Recursively import all modules from the given package.
|
||||
|
Loading…
x
Reference in New Issue
Block a user