Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Show Message Box Before Saving a Part

isocam
Collaborator

Show Message Box Before Saving a Part

isocam
Collaborator
Collaborator

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

0 Likes
Reply
Accepted solutions (1)
390 Views
1 Reply
Reply (1)

kandennti
Mentor
Mentor
Accepted solution

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()))

 

0 Likes