C++ / Python source code location (=path in repo) of FreeCADGui and FreeCADGui.Selection

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
derMart
Posts: 27
Joined: Tue Dec 28, 2021 10:50 pm

C++ / Python source code location (=path in repo) of FreeCADGui and FreeCADGui.Selection

Post by derMart »

Hi,

I am trying to start macro scripting and looking for documentation of the available Python bindings.
https://wiki.freecadweb.org/Selection_API is sadly quite incomplete, so I wanted to directly look at the source code which should give me everything I need (basically available functions, their signatures, object descriptions and what functions are doing).
Starting with the top level module FreeCADGui should give me everything I need by browsing its hierarchy.
However, I am having trouble to find the definition of FreeCADGui Python module in https://github.com/FreeCAD/FreeCAD/tree/master/src Can anyone help me out where it is defined?

PS: I Tried to look at https://freecad.github.io/SourceDoc/ but I did not find FreeCADGui neither in index, nor modules or classes. Then I looked at https://wiki.freecadweb.org/Exposing_Cp ... _to_Python which references the FreeCAD/src/Mod/* path. However, it seems that the next level in directory hierarchy are workbenches, so I also had no luck to find the FreeCADGui definition there. Any hint where this module is defined is highly appreciated :-)

thanks alot and best
Martin
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: C++ / Python source code location (=path in repo) of FreeCADGui and FreeCADGui.Selection

Post by onekk »

Probably under:

https://github.com/FreeCAD/FreeCAD/tree/master/src/Gui

You will find things related to the Gui.

But note that Python is not C++, so what is exposed by Python could be retrieved probablu more simply issuing:

Code: Select all

import FreeCADGui  ## maybe it will work even without this line
help(FreeCADGui)
But as it is very long it result in a truncation, however you could collect the output and print somewhere.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
edi
Posts: 481
Joined: Fri Jan 17, 2020 1:32 pm

Re: C++ / Python source code location (=path in repo) of FreeCADGui and FreeCADGui.Selection

Post by edi »

derMart wrote: Sun Nov 27, 2022 7:51 pm I am trying to start macro scripting and looking for documentation of the available Python bindings.
Python in FreeCAD has an included documentation. Open the Python console and type:

Code: Select all

>>> Gui.
The dot at the end is important. A scoll down window openes, showing in alphabetical order, all existing properties (starting with uppercas character) and functions (starting with lowercase character).
During scrolling down, a short "manual" describing the objects appeares. If you hit ENTER, the selected object is added to your line. Scroll down until 'Selection'. Hit ENTER and add a dot

Code: Select all

>>> Gui.Selection.
If you selected a function, you have to add manually two parenthesis. Scroll down until 'clearSelection'. Hit ENTER and add two parenthesis

Code: Select all

>>> Gui.Selection.clearSelection()
Hit ENTER to clear the selection.
Post Reply