List output of all commands

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
mmiscool
Posts: 73
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

List output of all commands

Post by mmiscool »

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
Effort on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access has been discontinued in favor of focused development on https://github.com/xibyte/jsketcher
User avatar
mmiscool
Posts: 73
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool »

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
Effort on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access has been discontinued in favor of focused development on https://github.com/xibyte/jsketcher
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: List output of all commands

Post by Kunda1 »

Is there a public repository you are building this on? Care to share it in the OP ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
mmiscool
Posts: 73
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool »

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
Effort on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access has been discontinued in favor of focused development on https://github.com/xibyte/jsketcher
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: List output of all commands

Post by mario52 »

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, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
mmiscool
Posts: 73
Joined: Sun Dec 18, 2016 9:07 pm
Location: Connecticut
Contact:

Re: List output of all commands

Post by mmiscool »

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
Effort on https://github.com/mmiscool/FC-Docker FreeCAD for cloud with browser based access has been discontinued in favor of focused development on https://github.com/xibyte/jsketcher
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: List output of all commands

Post by mario52 »

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, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply