[BUG?] Cannot get tooltip from commandDefinition

[BUG?] Cannot get tooltip from commandDefinition

tykapl.breuil
Advocate Advocate
341 Views
2 Replies
Message 1 of 3

[BUG?] Cannot get tooltip from commandDefinition

tykapl.breuil
Advocate
Advocate

Title is pretty self explanatory, setting a commandDefinition's tooltip works fine but getting it only returns an empty string. I have tested this on two different computers and I have had the same problem.

I have this problem for both custom and native commandDefinitions. Here is a sample code for the Extrude command, am I the only one with this problem ?

If this problem can be reproduced, how you I go about properly reporting this bug ? (is a forum post enough ?)

 

Sample Code :

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

app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface

def run(context):
    try:
        extrude = ui.commandDefinitions.itemById('Extrude')

        if extrude.tooltip:
            ui.messageBox(extrude.tooltip)
        else:
            ui.messageBox('empty string')
        
        extrude.tooltip = 'test'
        if extrude.tooltip:
            ui.messageBox(extrude.tooltip)
        else:
            ui.messageBox('empty string')
    
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
342 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Hi @tykapl.breuil .

 

I tried it, and sure enough, the tooltip was empty.

I tried all the CommandDefinitions, and some of them seem to be able to get tooltips.

# Fusion360API Python script

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

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

        for cmdDef in ui.commandDefinitions:
            try:
                tooltip = cmdDef.tooltip
            except:
                continue

            if len(tooltip) > 0:
                app.log(f'ID:{cmdDef.id} - {tooltip}')

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

 

However, it doesn't change the fact that it's not working correctly.

Message 3 of 3

tykapl.breuil
Advocate
Advocate

Checked your code and it's quite weird as the commandDefinitions for which it does work are seemingly random, apart from the fact that there seems to be most of the cad commands.

0 Likes