Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was wondering if it's possible to show message to user in these ways through api?
Solved! Go to Solution.
I was wondering if it's possible to show message to user in these ways through api?
Solved! Go to 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

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.
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