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: 

Ways to show message to user apart from message box

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
rolandas.vegis
824 Views, 4 Replies

Ways to show message to user apart from message box

I was wondering if it's possible to show message to user in these ways through api?

4 REPLIES 4
Message 2 of 5
marshaltu
in reply to: rolandas.vegis

Hello,

 

Unfortunately no. Please log your request in our idea station.

 

https://forums.autodesk.com/t5/fusion-360-ideastation/idb-p/125

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 5
BrianEkins
in reply to: rolandas.vegis

Actually, it is possible to show a message like the second example.  You do this by setting the executeFailed property of the CommandEventArgs object that passed into the command execute event to True.  And setting the executeFailedMessage property to whatever message you want to show up in the error dialog.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 5

Better late than never, this will show information to the user as a graphics text that is always facing the view and in a fixed location on the viewport.

 

 

   #Author-RM
#Description-

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

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        doc = app.activeDocument
        products = doc.products
        product = products.itemByProductType('CAMProductType')
        cam_var = adsk.cam.CAM.cast(product)
        desproduct = products.itemByProductType('DesignProductType')
        des = adsk.fusion.Design.cast(desproduct)
        root = des.rootComponent


        if not cam_var:
            ui.messageBox('No CAM data exists in the active document.')
            return

        #Checks the number of toolpaths and if they are generated    
        toolpathcount = cam_var.allOperations.count
        toolpathcheck = cam_var.checkToolpath(cam_var.allOperations)
  
        text = 'ToolpathNo = ' + str(toolpathcount) + "\nToolpathcheck Valid:" + str(toolpathcheck)

        #Displays as standard message box
        display = ui.messageBox(text)  

        #Displays as graphics on screen:
        # Check to see if a custom graphics groups already exists and delete it.
        if root.customGraphicsGroups.count > 0:
            root.customGraphicsGroups.item(0).deleteMe()
            app.activeViewport.refresh()
        graphics = root.customGraphicsGroups.add()

        matrix = adsk.core.Matrix3D.create()
        graphicsText = graphics.addText(text, 'Arial', 3, matrix)   
        # Set the text to be front facing and anchored at (0,0,0).
        billBoard = adsk.fusion.CustomGraphicsBillBoard.create(adsk.core.Point3D.create(0,0,0))
        billBoard.billBoardStyle = adsk.fusion.CustomGraphicsBillBoardStyles.ScreenBillBoardStyle 
        graphicsText.billBoarding = billBoard

        # Set the text to use view scaling.
        viewScale = adsk.fusion.CustomGraphicsViewScale.create(4, adsk.core.Point3D.create(0,0,0))
        graphicsText.viewScale = viewScale
        viewPlace = adsk.fusion.CustomGraphicsViewPlacement.create(adsk.core.Point3D.create(0,0,0),
                                                    adsk.fusion.ViewCorners.lowerLeftViewCorner, 
                                                    adsk.core.Point2D.create(10, 120))
        graphicsText.viewPlacement = viewPlace

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

def stop(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        #ui.messageBox('Stop addin')

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

 

 

Cheers,

 

RM

Message 5 of 5
simon-fliens
in reply to: BrianEkins

Could you give an example on how that would look like? 🙂

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