3d milling

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
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

3d milling

Post by JoshM »

I've continued work on scripting towards more controlled native 3d milling operations, and am finally at a point where things are beginning to come together. I still have a lot to implement, but as I look through the forum, I see lots of interest in the topic generally. I wanted to give a sense of what I'm trying to do as I think it's at a point where I can explain it and see what feedback I get...

As an algorithm, the concept--which can be roughly thought of as "carving the turkey", goes as follows:

--Parse the 3d model faces into toolpath envelopes that represent the maximal cut required to finish the face, without regard to other geometry or interference.

--This response is generated from the "finish" cut surface upward to the top height of the stock. My intent is that existing 2d paths (zig-zag, etc...) can be generated on the flat top surface, and used to decide how to actually implement the milling of that 3d space. Because the Tool-Path-Envelope is generated this way, it represents the area the "infinitely small" tool-center is allowed, for a tool of diameter D. The zig-zag path is therefore allowed any where within that surface--ideally, everywhere within it--and so the 2D offset can have an essentially 0.0 mm tool diameter Tool Diameter minimum for Path) specified, with offset specified only by the Step-Over parameter of the PathArea function.

--While parsing the geometry, a separate shape is generated for each face from the surface offset, downward to the stock bottom--a "Keep Out Zone", representing the closest that the specified mill is allowed to approach the surface without touching it.

--Once all faces have a "Maximal Tool Envelope" and a "Keep Out Zone", most of the calculation is set up. By using Keep-Out-Zones to carve away intersections with Maximal-Tool-Envelopes, the optimal available cut is almost realized. I say "almost" because I may need a 3rd response, which allows an over-ride of portions of Keep Out Zones--for example, if a half-cylinder is encountered, that also has cuts in the model...

What I've worked on to this point is generating a response to external solid/convex cylinders. I've done this so that much of the work translates directly to other similar geometries--Cones, Toroids, and Spheres are in line and will fall out of this. Flat faces are also fairly straight forward, and will be next in line to implement. Surfaces of extrusion and anything else using BSplines I'm kicking the can on because they are more complex.

Also falling out of this would be the ability to work on non-looped surfaces. My goal is that long term, this should calculate where the tool is allowed to exist relative to the 3d model, BUT, the selection of what operations are desired over what bounded area, would be a subset of the desired areas/operations within that envelope...


In the images attached, the calculations are done for a 4mm square-endmill on a cylinder with 310-degrees of inclusive angle, positioned to show the Maximal Toolpath Envelope generated at various angles. I don't show vertical, as I need to rework it now that I figured out angled/horizontal responses. The orange line represents the "Start" of the XY horizontal plane, the light blue line the "End". Silver and Brown lines show the geometry start/end for inclusive angles < 360-deg. A large yellow line shows the geometry surface axis, and then two reference lines represent the XY plane components of the +/- Surface Axis vector. A Point may be observed that marks the Mill-Radius offset.


Angled, inclusive upward.
Cylinder_0.png
Cylinder_0.png (162.89 KiB) Viewed 1610 times
Rotated around surface axis so that the "missing arc" is upward facing.
Cylinder_1.png
Cylinder_1.png (195.5 KiB) Viewed 1610 times
Now, horizontal.
Cylinder_2.png
Cylinder_2.png (163.08 KiB) Viewed 1610 times
At 9-deg from vertical.
Cylinder_3.png
Cylinder_3.png (175.55 KiB) Viewed 1610 times
I've only worked on square-mill to this point, but ballmill is actually easier as it's a straightforward 3d offset from surface to the center of the ball. The squaremill path is relative to the center of the tip of the mill, and that's why on horizontal cylinders, the tool is tangential to top of ellipse, but offset by mill radius at sides.

This image shows an error condition that I still need to trap, where the top ellipse is specified 180-degrees out, and the loft thus is wrong...
Cylinder_4.png
Cylinder_4.png (189.31 KiB) Viewed 1610 times
I've been working against Part WB geometric primitives, but am aware that PartDesign WB geometries require a bit of different handling to get the orientation correct in 3d space. As I said, lots to do to implement fully.

Note, the computation times are reasonable, and shown in the Report view.



Best,
Josh
Last edited by JoshM on Thu Jul 12, 2018 7:42 pm, edited 1 time in total.
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: 3d milling

Post by JoshM »

The macro and example file are attached here if anyone is interested in looking at them. The error shown above has been fixed.
-j
Attachments
SquareEndmillMillingToolpath.FCMACRO
(47.68 KiB) Downloaded 46 times
RotIndex11_Example.FCStd
(17.94 KiB) Downloaded 41 times
cahlfors
Posts: 91
Joined: Tue Jan 24, 2012 8:27 pm
Location: Sweden

Re: 3d milling

Post by cahlfors »

Awesome!
Thanks for working on this!

/Chris
electrical engineer
Ubuntu or Mint
Mendel 3d-printer/OctoPrint
LinuxCNC
Optimum BF20L mill
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: 3d milling

Post by chrisb »

+1
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: 3d milling

Post by JoshM »

I should make progress. ATM I'm shifting away from extruding an ellipse along an axis then lofting up to a face (same function, different angle input) though it works perfectly. I want to loft between 2 ellipses then loft up. That gets me back to wear I am now vis cylinders. But, Cones fall out easily by passing separate ellipsis minor / major radii. I'm almost there. interface and Top Loft Faces create, plus mean red font in the Report View :lol:
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: 3d milling

Post by JoshM »

I fought errors for a while, then realized making a loft of a loft is not supported in Part WB. I'm not sure why, because it supports making a loft of a facebinder of the loft.

I chose to switch to a Ruled Surface once I figured that out, and that's supported, so works well. I have cylinders back again, and will realize cones quite soon. I need to flesh out functions to act on Cone surface found, and pass the correct ellipse terminal radii and it will look like this example, where I hard coded the radii to match the cone shown here...
Cone_1.png
Cone_1.png (252.44 KiB) Viewed 1549 times
Tomorrow, I'll flesh that out.
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: 3d milling

Post by JoshM »

I've worked out cones as well as cylinders. Cylinders are after all, a special--simpler--cone. Shown are the equivalent cylinder and cone, and the toolpath envelopes generated.
Cone_3.png
Cone_3.png (310.73 KiB) Viewed 1472 times
I show a zig-zag/offset pattern, 1mm step, 0.0001mm diameter Tool. This highlights an upside of generating tool-path envelopes allowing minimum diameter tool size. Think of every instance where you have some face that will not fit the tool diameter, but actually millable because not near obstacles... I haven't dug into it yet, but if a top-overlayed tool-path is projected down at steps heights, the toolpath envelope bounds the usable portion...
Attachments
SquareEndmillMillingToolpath.FCMACRO
(55.59 KiB) Downloaded 41 times
Post Reply