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: 

How to see inside python variables?

3 REPLIES 3
Reply
Message 1 of 4
eric
596 Views, 3 Replies

How to see inside python variables?

Heres the 'default' hello app

def run(context):

ui = None

try:

app = adsk.core.Application.get()

ui = app.userInterface

 

So, simple question, theres app and ui, I know nothing about whats 'inside' them, how can I see all the members values inside them?

 

If I print(ui) I get garbage....<adsk.core.UserInterface; proxy of <Swig Object of type 'adsk::core::Ptr< adsk::core::UserInterface > *' at 0x0000029F4008D0C0> >

 

To say this output is unhelpful is being overly generous....

So, again, how exactly can I see all the exposed public member variables of ui?  or app?

 

Thanks

 

 

 

 

3 REPLIES 3
Message 2 of 4
marshaltu
in reply to: eric

Hello,

 

If you use Spyder which embedded in Fusion 360 to write Python codes, you can probably see code hint when you type and detailed information in Object Inspector.

 

In addition, you should also be able to get information from our help http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-A92A4B10-3781-4925-94C6-47DA85A4F65A .

 

Thanks,

Marshal

 

CodeHint.pngObject inspector.png



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 4
kevin
in reply to: marshaltu

Just use Visual Studio Community for free w/ Python & C++ so your covered both ways

You also get the added benefits of syncing your profile to cloud

Also Versioning with Team Services since Fusioin 360 Cloud doesn't sync scripts and they are hidden in weird folders to manage

 

https://www.visualstudio.com/vs/features/python/

 

Debugging-1-800x630.pngTeam Services.png

Message 4 of 4
JeromeBriot
in reply to: eric

Hello,

 

use dir (Built-in Functions) instead of print:

dir(ui)
['__class__', '__del__', '__delattr__', '__deref__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__swig_getmethods__', '__swig_setmethods__', '__weakref__', '_get_activeCommand', '_get_activeSelections', '_get_activeWorkspace', '_get_allToolbarPanels', '_get_commandCreated', '_get_commandDefinitions', '_get_commandStarting', '_get_commandTerminated', '_get_isValid', '_get_markingMenuDisplaying', '_get_objectType', '_get_palettes', '_get_toolbars', '_get_workspaceActivated', '_get_workspaceDeactivated', '_get_workspacePreActivate', '_get_workspacePreDeactivate', '_get_workspaces', '_s', 'activeCommand', 'activeSelections', 'activeWorkspace', 'allToolbarPanels', 'cast', 'classType', 'commandCreated', 'commandDefinitions', 'commandStarting', 'commandTerminated', 'createFileDialog', 'createFolderDialog', 'createProgressDialog', 'inputBox', 'isValid', 'markingMenuDisplaying', 'messageBox', 'objectType', 'palettes', 'selectEntity', 'terminateActiveCommand', 'this', 'toolbarPanelsByProductType', 'toolbars', 'workspaceActivated', 'workspaceDeactivated', 'workspacePreActivate', 'workspacePreDeactivate', 'workspaces', 'workspacesByProductType']

And, to me, one of the most important thing when you start to use a new API is its documentation. See UserInterface Object

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