How to create CNC paths by script

Hello everybody,

I’m looking for a script to create CNC paths.
as a start, a line on the solid should be duplicated and extended by an original factor. Another line on the solid should serve as the second input. This second line is also to be extended by an original factor.
Now two perpendicular connecting lines to the second line have to be created and the second line has to be trimmed.
Main geometry layer: 5-axis
Layer of the connecting lines: 5-axis across

First Step:
Second Step:
Third Step:

Thanks for your help

Hi Gerbert,

Are you looking for python script, VB script, grasshopper script for this kind of process.

Have you also looked at some of the other topics on cnc as there are already examples out there.
Have you also attempted to do what you are trying to do via script, or are you hoping for someone to give you a solution?

Why dont you code it yourself? It is not so difficult, you just need to invest time.

If you do not want to, then there are number of plugins that will do it for you on food4rhino.
Also it depends on 5 axis machine you have i.e. the A and B rotations of motor, that will be different from machine to machine.

hello and thanks for your feedback.
My knowledge of Rhino Script or Phyton is not so extensive that I can work out a possible solution myself. My hope is that I can find and use something available in this forum.
I only need the described paths in CAD and implement them appropriately in CAM as processing.

Hello and thank you for your feedback.
I’m looking for a solution in Rhino Script or Phyton.
unfortunately I have not found anything suitable in the forum. My level of knowledge is not sufficient to solve the problem and I hope for the help of the “script pro´s”

I developed a CNC tool-path grasshopper plugin for IBOIS, EPFL, and we already tested that for several projects, I can upload the code on Github.

But again, every CNC machine has its own post-processor, ours works on G-Code and we have two methods for converting plane Z axis to A and B rotations of CNC.

Also, have you tried RhinoCam or MadCam, they are good software, and as a starting point I would recommend to test that.


Hello Petras,

Thanks for your answer.
wow, a very interesting project.
to the question about the CNC machine and the G code generation:
I only used Rhino as CAD software and would like to create the required geometries here, I use Alpha-CAM to create the program.
In Alpha-CAM only the lines are automatically occupied and the CNC program is generated with the appropriate post.
Here I need the lines for 5-axis milling. At the moment I have to draw them by hand, but automation would be an advantage.

Hello Gebert C,
RhinoCAM may able to produce a similar toolpath without having to create additional curves in Rhino as you can select surface/face edges from your solid/surface geometry as drive curves to generate toolpaths.
Feel free to download RhinoCAM demo to test your file: . If you have questions, please feel free to contact us at

Hey @Petras_Vestartas,

regarding your suggestion here, how would you do this, where to start? Can you recommend something?

What I am looking for is a way to create tool-paths for milling that a robot (UR10e) could use.
Coding it myself would also be an option, though I am not quite sure if the approach I am thinking of is the best. Would it make sense to do a mix of horizontal and vertical slicing to create the paths based on the tool-radius, speed, etc., which are then used by the GH-Plugins HAL, Robots, or COMPAS Fab to create the paths for the robot?

Would be amazing if I could get your thoughts on that!

Depends how fast and how good you want to machine parts…

Gcode is easy, machining stuff is not and programs that make it easy to do cam stuff
with stragegies, operation types, tool changing… etc is just a quagmire i would not want to think of.

Even writing a g code generator (easy for squares), etc yeah easy. But feeds, speeds, accelarations, helixes, optimizing machine moves… You can code that for ages!

Learning GCode allowed me to write automated editors but i haven’t dug down 3D code and optimizing some code… There’s just too many options.

Look at Vectrix Aspire options and RhinoCAM options… It’s the two i know and you are productive right away. One is easy, the other is options galore, better finish (IMOHO). Learning curve is medium to very high (same price) - Imagine if you had to learn and code it.

Search for 3D printing in this forum, also quite fun… And there’s a module for Robot programming somewhere… (If i find it, i will post it here later)

Thanks for your reply, @xavier.bury. It saved me quite some time building my own tool.

For now, I am using Fusion 360 to create the paths, since it is free for me as a uni student. The coordinates are exported as a CSV and then imported in GH to control the robot. Not the most convenient, but it seems to work… :slight_smile:

going from model to cnc workflow is horrible,
If it works, fine… Im still trying to find that sweet spot…