What does FreeCAD use to embedded Python to C++

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
haonk
Posts: 19
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

What does FreeCAD use to embedded Python to C++

Post by haonk »

Hi!
i am new in Python and C++, i wanna improving FreeCAD source code. But i do not know how did it embedded Python into C++.
I am searching in Google and find something: pybind11, CPython and Boost.Python. So, what does we use for FreeCAD? i wanna know to learning, please help me!
wmayer
Founder
Posts: 20305
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: What does FreeCAD use to embedded Python to C++

Post by wmayer »

haonk wrote: Fri Jul 19, 2019 4:54 am Hi!
i am new in Python and C++, i wanna improving FreeCAD source code. But i do not know how did it embedded Python into C++.
I am searching in Google and find something: pybind11, CPython and Boost.Python. So, what does we use for FreeCAD? i wanna know to learning, please help me!
We use several Python binding libraries. boost.python or alternatively pybind11 is used for the flatmesh and area modules. But for the vast majority we use our own wrapper. For a class to be wrapped an XML file must be provided and an *Imp.cpp file where the C++ <-> Python stuff is done. The framework is very close to how it's described in the section of embedding in the Python documentation.
haonk
Posts: 19
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

Re: What does FreeCAD use to embedded Python to C++

Post by haonk »

wmayer wrote: Fri Jul 19, 2019 8:55 am We use several Python binding libraries. boost.python or alternatively pybind11 is used for the flatmesh and area modules. But for the vast majority we use our own wrapper. For a class to be wrapped an XML file must be provided and an *Imp.cpp file where the C++ <-> Python stuff is done. The framework is very close to how it's described in the section of embedding in the Python documentation.
And how about GUI? what does we use for FreeCAD? i see PySide, PyQt in FreeCAD project
Where should i start?
wmayer
Founder
Posts: 20305
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: What does FreeCAD use to embedded Python to C++

Post by wmayer »

And how about GUI? what does we use for FreeCAD?
The above mentioned libraries are used to write your own Python wrappers for C++ classes while PySide is an already 3rd party wrapper for Qt which we can use as is.
haonk
Posts: 19
Joined: Wed Jun 05, 2019 3:11 am
Location: VietNam

Re: What does FreeCAD use to embedded Python to C++

Post by haonk »

wmayer wrote: Mon Jul 22, 2019 9:00 am The above mentioned libraries are used to write your own Python wrappers for C++ classes while PySide is an already 3rd party wrapper for Qt which we can use as is.
Thanks!!! but i have an question!
Just like Arch or Draft workbenches, Can I using only Python to create a new module? or i have to use both if i want a perfectly module?.
I didn't know about C++
chrisb
Veteran
Posts: 54188
Joined: Tue Mar 17, 2015 9:14 am

Re: What does FreeCAD use to embedded Python to C++

Post by chrisb »

You may have a look at the several addon workbenches to see how they build the GUI and interface with FreeCAD structures.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply