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.
This commit is contained in:
@@ -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
|
||||
# =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user