About path module development

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
2219566359
Posts: 2
Joined: Thu Nov 25, 2021 3:46 am

About path module development

Post by 2219566359 »

Hello everyone, I am a newbie in programming, I recently learned the FreeCAD cam module, and I am currently experiencing some problems.
1. Is the core algorithm of path module in FreeCAD developed on the basis of OpenCASCADE library?
2. I want to imitate FreeCAD and make a small cam program by myself, how should I learn it? Look directly at the source code of the path module part?
I would appreciate any guidance!!
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: About path module development

Post by sliptonic »

The core of Path is written in c++ and is very simple. It's a small set of objects that handle the storage and visualization of Path "commands" which roughly correspond to gcode. These objects also have a python interface. The basics of using them with python for creating a toolpath are pretty easy and documented on the path scripting wiki page.

Most of path is written in python but uses some important c++ libraries. These include PathArea which does polygon offsetting with the clipper algorithm and OpenCamLib for 3D surfacing.

The complexity of Path comes from all the rest of the stuff you have to take into account; managing tools, setting up jobs and coordinate references, selecting target geometry, holding tags, start points, post-processing for specific machines, etc, etc, etc.

Also, like the rest of Freecad the core and gui aspects of objects are separated. You should thoroughly understand pythonFeature objects and view providers. Lots of good documentation on the wiki.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: About path module development

Post by onekk »

To add some thing to @sliptonic (one of the main if not the lead developer of Path).

a CAM program is not so easy to make, you have to know some things (And for sure I'm missing something):
  1. How GCode is working.
  2. How your machine is interpreting GCode, many things depends to the controller used.
  3. some vector math and 3D math.
  4. how to extract relevant data from the "original objects" like a DXF drawing for 2 or 2.5 operation or some solid format (not mesh format) for 3D operation.
  5. How precisely are 2D, 2.5D, 3D operation in CAM there are many misunderstanding, on how 3D is really with CNC.
  6. How to read sources in C++ and Python (If you want to reuse some FreeCAD code) and even some Graphics Toolkit programming, (QT, Wxworks, WxPython, FLTK, only to name something)
Usually CAM is not for beginners at all.

But good luck and maybe ask for something, and here there will be some people that may drive you through difficulties.

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/
2219566359
Posts: 2
Joined: Thu Nov 25, 2021 3:46 am

Re: About path module development

Post by 2219566359 »

I am going to learn the basic principles first, and then analyze the code, thank you for your guidance! :D
Post Reply