Ways to show message to user apart from message box

Ways to show message to user apart from message box

rolandas_vegis
Advocate Advocate
2,364 Views
4 Replies
Message 1 of 5

Ways to show message to user apart from message box

rolandas_vegis
Advocate
Advocate

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

0 Likes
Accepted solutions (1)
2,365 Views
4 Replies
Replies (4)
Message 2 of 5

marshaltu
Autodesk
Autodesk
Accepted solution

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 Developer
>
0 Likes
Message 3 of 5

BrianEkins
Mentor
Mentor

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

rmerlo_Gamma
Observer
Observer

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__H
Explorer
Explorer

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

0 Likes