Hi @sharas_s .
I tried it too, but it didn't work.
Why don't you try to get the desired version of the DataFile from the versions property?
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9C14590B-1189-4A19-9438-3F6F2C9ABA85
Here is a sample to get the DataFile of the previous version of the active document.
# Fusion360API Python script
import adsk.core, adsk.fusion, traceback
def run(context):
ui = adsk.core.UserInterface.cast(None)
try:
app :adsk.fusion.Application = adsk.core.Application.get()
ui = app.userInterface
# get active doc datafile
doc = app.activeDocument
dataFile: adsk.core.DataFile = doc.dataFile
# get previous version datafile
previousVersionDataFile = getPreviousVersionDataFile(dataFile)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def getPreviousVersionDataFile(
dataFile: adsk.core.DataFile) -> adsk.core.DataFile:
currentVersion = dataFile.versionNumber
if currentVersion < 2:
return None
dfs = [df for df in dataFile.versions if df.versionNumber == currentVersion - 1]
if len(dfs) < 1:
return None
return dfs[0]