Read File Version from API?

Read File Version from API?

ahalekelly
Explorer Explorer
675 Views
3 Replies
Message 1 of 4

Read File Version from API?

ahalekelly
Explorer
Explorer

I'm writing a script to engrave information about the design into the part and then export an STL for 3D printing. I've figured out how to do this with model parameters, but I can't figure out how to read the version number of the file within the API. Is this possible?

0 Likes
Accepted solutions (1)
676 Views
3 Replies
Replies (3)
Message 2 of 4

JeromeBriot
Mentor
Mentor
Accepted solution

Hello,

 

here is a Python code to get the lastest version number:

 

 

import adsk.core, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()

        ui  = app.userInterface

        doc = app.activeDocument

        df = doc.dataFile

        ui.messageBox('{}'.format(df.latestVersionNumber))

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Read the documentation about the DataFile Object.

 

Hope this helps.

 

Message 3 of 4

ahalekelly
Explorer
Explorer

Thank you! That works great.

0 Likes
Message 4 of 4

BrianEkins
Mentor
Mentor

Just be aware that the version being returned is the latest saved version of the design.  If you open an existing design and make changes to it, it's theoretically a new version but that new version isn't actually created until you save it.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes