Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read File Version from API?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
ahalekelly
402 Views, 3 Replies

Read File Version from API?

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?

3 REPLIES 3
Message 2 of 4
JeromeBriot
in reply to: ahalekelly

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
in reply to: JeromeBriot

Thank you! That works great.

Message 4 of 4
BrianEkins
in reply to: ahalekelly

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report