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: 

file name expression

5 REPLIES 5
Reply
Message 1 of 6
simeonX24F9
646 Views, 5 Replies

file name expression

hello

 

does somebody know the file name expression? 

 

i want to have the name of the file i am working on always show up in program comment on a new setup......

Capture.PNG

5 REPLIES 5
Message 2 of 6
JeromeBriot
in reply to: simeonX24F9

Hello,

 

Try this example:

import adsk.core, adsk.fusion, adsk.cam, traceback

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

        docName = app.activeDocument.name

        ui.messageBox(docName)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Tags (2)
Message 3 of 6
simeonX24F9
in reply to: JeromeBriot

This doesn't seen to work. And it doesn't stay. Next time I go to edit it is
gone
Message 4 of 6
JeromeBriot
in reply to: simeonX24F9

I should have read your post more carefully before replying.

AFAIK, it's not possible to use the API to populate a opened dialog.

 

Message 5 of 6

Did you ever find a way to do this?  I have been looking for the same thing.  It would be immensely more maintainable to have CAM files matching the part name perhaps concatenated with the setup name automatically. 

Message 6 of 6

Here's a little script that should do it.

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    app = adsk.core.Application.get()
    ui = app.userInterface
    try:
        # Get the design from the active document.
        doc = app.activeDocument
        des: adsk.fusion.Design = doc.products.itemByProductType('DesignProductType')
        cam: adsk.cam.CAM = doc.products.itemByProductType('CAMProductType')

        # Get the first setup in Manufacturing.
        setup = cam.setups[0]

        # Get the parameter for the program comment.
        param = setup.parameters.itemByName('job_programComment')

        # Change the value to the same name as the document.
        stringVal: adsk.cam.StringParameterValue = param.value
        stringVal.value = doc.name        
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
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