Generic blank NewOp machining operation

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Posts: 49
Joined: Tue Oct 23, 2018 3:35 pm

Generic blank NewOp machining operation

Postby JulianTodd » Wed Nov 07, 2018 7:42 pm

I'm still looking at the possibility of contributing a machining operation. This is best done by cloning from a generic blank machining operation.

sliptonic made a start here in this comment thread:
He referred to this github branch of the FC.
(I've cloned this, checked it out, and compiled from scratch again.)

There are further details here: ... g-for-Path

** If we did develop a model NEWOP, it might be worthwhile putting all these instructions into the comments in the source-code to make them easier to follow.

The operations I'd like to develop might best be calculated in separate subprocesses. So, ideally, we'd save an STL file of the model, a properties file of things like toolshape, tolerance, stepdown -- and the calculated toolpaths would return through the stdout of the process.

Developing the FC code

The following cannot be the best way to do this, but I just had to get somewhere.

I made a FC file with a JOB and a NEWOP operation and have been hacking the file: ...
in the place it's been copied in the build directory:

I set the logging level to debug:

Code: Select all

   PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
and have been inserting logging messages into opExecute() to find what these components hold:

Code: Select all
There is no way to cause the script to reload when I edit it, so I'm having to close and reopen the whole of FC for every iteration cycle.

I've managed to generate a ZigZaggy toolpath in the opExecute() function, like this:

Code: Select all

        for i in range(21):
            self.commandlist.append(Path.Command("G1", {"X": [bb.XMin,bb.XMax][i%2], "Y":bb.YMin + (bb.YMax-bb.YMin)*i/20.0, "Z": bb.ZMax, "F": 101}))
This proves I can get a toolpath output into the UI.

I can also save an STL file, like this:

Code: Select all

        for base in self.model:
            m = MeshPart.meshFromShape(base.Shape)
            m.write("test_%s.stl" % base.Name)
This writes the file "test_Clone.stl". I don't know where that name came from.

So I need help getting this PathNEWOP module into a completed state, particularly with:
(1) finding the correct Shape to dump into the stl-file,
(2) dumping out all the properties/parameters into a second file, one per line,
(3) streaming the toolpath motion code back from the stdout of the calculating process, back into the FC ui so you can see the progress.
Posts: 1124
Joined: Fri Sep 16, 2016 9:28 pm

Re: Generic blank NewOp machining operation

Postby mlampert » Thu Nov 08, 2018 6:54 pm

Do you have a github repo with your changes? I can make you an op, or look into make what you have work and create a PR to your repo.

You can replace a python file without having to restart, but it does not replace/affect/modify any existing objects in your FC instance. So this is no good for installed command handlers, menu entries and such. The process goes like this on the python console:

Code: Select all

import PathScripts.YourFile as YourFile
... try your stuff, make changes ...
... try new implementation ...
Assuming your op is in

I'm not sure if you compile FC or if you're trying to add an op into a binary deployment - in case you are compiling, this is my typical setup which has been working for me (on Debian Testing):

Code: Select all

  +- dev
  |  +- FreeCAD
  |  \- build
The FreeCAD directory holds the cloned git repo, splitting the build directory makes it easy to start from scratch. replaces some directories in the build tree with symlinks back into the source tree, so I don't have to copy python files back and forth, all call make all the time. I've attached the two scripts, you might have to adapt to your particular setup.
(286 Bytes) Downloaded 4 times
(1.84 KiB) Downloaded 5 times