This article provides a code snippet to save a document to a local DXP file using IronPython.
Introduction
Use the following method: AnalysisApplication. SaveAs Method (String, DocumentSaveSettings)
It is not straightforward to do this before Spotfire 7.5, because it tries to execute a progress operation inside an existing transaction. Spotfire 7.5 has a checkbox on the IronPython editor that you can uncheck to prevent the script from executing inside a transaction. The script below should work in the versions prior to 7.5 .
Code sample
# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license. # Import namespaces from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread from Spotfire.Dxp.Application import DocumentSaveSettings from Spotfire.Dxp.Framework.Library import * # Declaring the function which will run async def g(app,fileName,saveSettings): def f(): app.SaveAs(fileName, saveSettings) return f # Set the file name fileName = "D://Temp//Test File2.dxp" # Executing the function on the application thread, and Save the document back to the Library Application.GetService[ApplicationThread]().InvokeAsynchronously(g(Application, fileName,DocumentSaveSettings())) # Note: # The function g is necessary because the script's scope is cleared after execution, # and therefore Application (or anything else defined in this scope) will not be available # when the code invokes on the application thread.
References
License: TIBCO BSD-Style License
Recommended Comments
There are no comments to display.