List output of all commands

A forum for research and development of the user interface of FreeCAD

Moderator: agryson

Post Reply
User avatar
mmiscool
Posts: 63
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

List output of all commands

Post by mmiscool » Fri Jan 03, 2020 11:19 pm

Hello,
I have been working on a concept for an alternative ribbon style UI for freecad. If i can get some code to do the following 3 things I think I will be well on my way to implementing the idea.

First I am hoping that there is a simple way of programmatically list all of the commands available in the GUI along with the current status of those commands (available / unavailable, clickable or grayed out). I know this information must be available some where because of the toolbar customization tool.

Second I would need an example of some python code to activate or run an arbitrary command from the list as if the user had clicked the command from the menus.

Third I would like to be able to export PNG images for each of the icons associated to the commands.

Thanks for any help.
My main project is https://autodrop3d.com
Working on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access.
User avatar
mmiscool
Posts: 63
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool » Sat Jan 04, 2020 10:58 am

I managed to get a listing of commands by exploring the Gui object.

It seems that the follwing code will give me a listing of the each of the commands as an array
print(Gui.listCommands())

Using the Gui.doCommandGui I can execute the command.
print(Gui.doCommandGui("name of command as astring")



I am still struggling to get the status of commands (enabled/or grayed out) and figuring out the icon file associated with each.

Any help would be appreciated.
My main project is https://autodrop3d.com
Working on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access.
User avatar
Kunda1
Posts: 6463
Joined: Thu Jan 05, 2017 9:03 pm

Re: List output of all commands

Post by Kunda1 » Sat Jan 04, 2020 1:32 pm

Is there a public repository you are building this on? Care to share it in the OP ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
mmiscool
Posts: 63
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool » Sat Jan 04, 2020 10:52 pm

Not quite yet. This is actually a smaller portion of a larger project.

I do plan on putting some thing out after I get this part of it working. People should be pleasantly surprised by it I think.

And any snippets of code for outputting a listing of GUI commands and there status as to being enabled or disabled would be extremely helpful.
My main project is https://autodrop3d.com
Working on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access.
mario52
Posts: 2807
Joined: Wed May 16, 2012 2:13 pm

Re: List output of all commands

Post by mario52 » Sun Jan 05, 2020 12:48 pm

hi

good idea

run the command:

Code: Select all

>>> Gui.runCommand('Draft_Arc',0)
>>> Gui.runCommand('Std_Macro_11',0)
....
for the icon in and image in gui
Qt_Example

for the icon in "FreeCAD" on a button

Code: Select all

        self.image_04 = QtGui.QIcon.fromTheme("edit-delete")                     # icone resource de FreeCAD sur bouton
        self.PB_Quit.setIcon(self.image_04)                                      # icone resource de FreeCAD sur bouton

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
User avatar
mmiscool
Posts: 63
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool » Sun Jan 05, 2020 1:24 pm

Thanks for the reply there Mario.

I am looking to extract the icon file associated with a command from the command. This way I can export it. Not trying to assign an icon file to a custom command.
My main project is https://autodrop3d.com
Working on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access.
mario52
Posts: 2807
Joined: Wed May 16, 2012 2:13 pm

Re: List output of all commands

Post by mario52 » Sun Jan 05, 2020 1:34 pm

hi

see "for the icon in "FreeCAD" on a button" above

example usage Gui.runCommand() Std_DrawStyle

other example use Gui.runCommand() [Macro] Bit of help for super users by openBrain

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Dialog creation. My macros on Gist.github.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest