Message 1 of 14
SaveAs multiple documents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
First I wanted to say hello because this is my first post.
The script below should save the currently open document under new names 3 times. Unfortunately, during operation, the program saves only one document, but v3
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
document = app.activeDocument
path = design.parentDocument.dataFile.parentFolder
baseName = document.dataFile.name
for idx in range(3):
if not document.isSaved:
ui.messageBox(
"The active document must be saved before running this script."
)
return
newFilename = f"{idx}_{baseName}"
document.saveAs(newFilename, path, "Dec", "Tag")
except:
ui.messageBox("Failed:\n{}".format(traceback.format_exc()))
Below are some pictures of the process from start through recording and the end result
How can I force this script to get 3 new correctly saved documents at the end?