From 27e112e7da5eafe38d02b255e38013879c231a02 Mon Sep 17 00:00:00 2001 From: forbes-0023 Date: Thu, 5 Feb 2026 14:02:07 -0600 Subject: [PATCH] feat(origin): add interactive open/saveAs methods to SiloOrigin Add openDocumentInteractive() and saveDocumentAsInteractive() methods to support the updated FileOrigin interface from Issue #10/#12. - openDocumentInteractive: Delegates to Silo_Open command for search dialog - saveDocumentAsInteractive: Triggers new item creation form for Save As These methods enable the Std_* commands in FreeCAD to delegate to SiloOrigin when Silo is the active origin. --- pkg/freecad/silo_origin.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pkg/freecad/silo_origin.py b/pkg/freecad/silo_origin.py index 29892d3..d78600c 100644 --- a/pkg/freecad/silo_origin.py +++ b/pkg/freecad/silo_origin.py @@ -329,6 +329,24 @@ class SiloOrigin: FreeCAD.Console.PrintError(f"Silo open item failed: {e}\n") return None + def openDocumentInteractive(self): + """Open document interactively via Silo search dialog. + + Shows the Silo_Open dialog for searching and selecting + a document to open. + + Returns: + Opened App.Document or None + """ + try: + cmd = FreeCADGui.Command.get("Silo_Open") + if cmd: + cmd.Activated() + return FreeCAD.ActiveDocument + except Exception as e: + FreeCAD.Console.PrintError(f"Silo open failed: {e}\n") + return None + def saveDocument(self, doc) -> bool: """Save document and sync to Silo. @@ -402,6 +420,26 @@ class SiloOrigin: ) return False + def saveDocumentAsInteractive(self, doc) -> bool: + """Save document interactively with new identity. + + For Silo, this triggers the new item creation form which allows + the user to select category and create a new part number. + + Args: + doc: FreeCAD App.Document + + Returns: + True if operation succeeded + """ + if not doc: + return False + + # For Silo, "Save As" means creating a new item + # Trigger the new item creation form + result = self.newDocument() + return result is not None + # ========================================================================= # Extended Operations # =========================================================================