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: 

Show Message Box Before Saving a Part

1 REPLY 1
SOLVED
Reply
Message 1 of 2
isocam
183 Views, 1 Reply

Show Message Box Before Saving a Part

Can anybody help?

 

Is it possible, using a Python script, to show a Message Box before saving a part in Fusion 360???

 

For example, 

 

Say I have created a simple sketch and extruded it.

 

I now want to save it.

 

Normally, I would press "SAVE" and manually enter the name of the part (Default shows "Untitled").

 

Is it possible to show, for testing purposes only, a message box saying "Hello World" before the "Save" dialog POP-UP box appears?

 

Many thanks in advance!

 

Darren

1 REPLY 1
Message 2 of 2
kandennti
in reply to: isocam

Hi @isocam .

 

This can be done by using the documentSaving event.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-303438FA-9744-4C0B-9908-40BEE4184CE1 

 

Based on the sample add-in here, I modified it to a minimal state.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-a445a970-997b-11e5-b40a-3417ebd3d5be 

# Fusion360API Python Addin
import adsk.core, traceback

handlers = []
ui = None

class MyDocumentSavingHandler(adsk.core.DocumentEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        ui.messageBox('HelloWorld')     

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

        onDocumentSaving = MyDocumentSavingHandler()
        app.documentSaving.add(onDocumentSaving)
        handlers.append(onDocumentSaving)
    except:
        if ui:
            ui.messageBox('AddIn Start Failed:\n{}'.format(traceback.format_exc()))

def stop(context):
    try:
        pass
    except:
        if ui:
            ui.messageBox('AddIn Stop Failed: {}'.format(traceback.format_exc()))

 

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