3d milling algo
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
3d milling algo
I think I have figured out a method that I believe can be expanded to add some further 3d milling functionality.
This method can be readily expanded to handle more shapes. It's still fairly preliminary, and (among other things) I don't think I have vertical cylinders bounded, but here's the gist.
Here's an example of generating "roughing" passes for a Square Endmill on a cuboid placed at an angle with two adjacent filleted angles.
1. For the selected Job,
a Stock Model, and a Tool Stock Model that expands the Stock Model by the Mill Radius in XY.
2. For each Face the sections that are accessible to mill from the Top-Z direction are determined from the intersection of a local Face Boundbox3d, aligned with the axis of the Face.
3. For each Face section, the OuterWire edges are discretized. For each discrete point I get the normalAt( Surface.parameter(discrete_point)). I zero the Z of that vector, and multiply by the MillRadius,and that generates the ideal "Finish Cut" surface covering all points where the center of the Mill tip can pass to mill an Operation. While generating that outline, its projection onto the StockTop is created, and the Loft of the two Faces is the ToolPathEnvelope.
4. A Path.Feature.Area is generated, with minimal Tool Radius specified because this assumes center of tool pocketing. The PocketMode is set at Offset, but can be changed to any other mode--ZigZag, etc...
5. This is proof of concept of a "roughing" mode, because it still operates on discrete Z heights. To create a "proper" 3d milling profile, the non-planar Finish-Face requires dividing in 3d like FeatureArea does for 2d. I tried the extruding the 2d top paths downward and getting intersection, but no never calculated.
Calculating shape and calculating Paths are about equal for this shape, vary for others...
This method can be readily expanded to handle more shapes. It's still fairly preliminary, and (among other things) I don't think I have vertical cylinders bounded, but here's the gist.
Here's an example of generating "roughing" passes for a Square Endmill on a cuboid placed at an angle with two adjacent filleted angles.
1. For the selected Job,
a Stock Model, and a Tool Stock Model that expands the Stock Model by the Mill Radius in XY.
2. For each Face the sections that are accessible to mill from the Top-Z direction are determined from the intersection of a local Face Boundbox3d, aligned with the axis of the Face.
3. For each Face section, the OuterWire edges are discretized. For each discrete point I get the normalAt( Surface.parameter(discrete_point)). I zero the Z of that vector, and multiply by the MillRadius,and that generates the ideal "Finish Cut" surface covering all points where the center of the Mill tip can pass to mill an Operation. While generating that outline, its projection onto the StockTop is created, and the Loft of the two Faces is the ToolPathEnvelope.
4. A Path.Feature.Area is generated, with minimal Tool Radius specified because this assumes center of tool pocketing. The PocketMode is set at Offset, but can be changed to any other mode--ZigZag, etc...
5. This is proof of concept of a "roughing" mode, because it still operates on discrete Z heights. To create a "proper" 3d milling profile, the non-planar Finish-Face requires dividing in 3d like FeatureArea does for 2d. I tried the extruding the 2d top paths downward and getting intersection, but no never calculated.
Calculating shape and calculating Paths are about equal for this shape, vary for others...
Re: 3d milling algo
Here, I've changed the PocketMode to ZigZagOffset--and 5-6 seconds later...
- Attachments
-
- SquareEndmillMillingToolpath.FCMACRO
- (16.66 KiB) Downloaded 41 times
Re: 3d milling algo
Here's a separate example, a simple partial cylinder, at an angle.
Re: 3d milling algo
I've worked further on this, and made some progress.
1--I've added in Plane Objects to Cylinders.
2--I realized I misunderstood the Feature.Area PocketMode settings. I had set the Tool-Radius very small because unlike typical operations, I am calculating referenced to Center of Tool. The result is that the very center gets a TON of offset lines calculated, filling the inner Step size. I moved that to match the Step-over size. This makes the "roughing' demo much faster, and I believe it adds utility in its own right.
3--For prototyping this script, I am now selecting a Job, and a Tool-Controller and running the script. If only a Job is selected, the default tool-controller is used.
Here's the same Job Model. The 2.37 second time is only generating the roughing Pocket on top--add a couple more seconds when I set the Section Count to -1 to get the roughing paths.
The gaps observed between Face sections are because the algo generates a Face claim that gets an edge of the mill tangential to all points of the Face OuterWire. The tool mills by its radius past the response envelope/surfaces that I am generating.
The model generated allows bounded face by face control--very atomic--of the Job Model. Next Image, switches to Zig-Zag Outline PocketMode.
4--I implemented the response for BallEndMills along with the SquareMill tool responses I have been working on. It's relatively trivial to work with Square and Ballnose endmills because the normalAt() function provides the basis for each. For Square, the z-component is zeroed. For the Ballnose, an offset in Z of the Mill radius is added so that it is Tool Tip referenced--same as with square...
BTW, I already researched months ago, and Rounded Edge mills will fall out of the same calculation as a combination square and ballnose geometries where the Corner Radius and Flat Radius generate radial offset paths to the OuterWire. I just haven't gotten it done yet.
1--I've added in Plane Objects to Cylinders.
2--I realized I misunderstood the Feature.Area PocketMode settings. I had set the Tool-Radius very small because unlike typical operations, I am calculating referenced to Center of Tool. The result is that the very center gets a TON of offset lines calculated, filling the inner Step size. I moved that to match the Step-over size. This makes the "roughing' demo much faster, and I believe it adds utility in its own right.
3--For prototyping this script, I am now selecting a Job, and a Tool-Controller and running the script. If only a Job is selected, the default tool-controller is used.
Here's the same Job Model. The 2.37 second time is only generating the roughing Pocket on top--add a couple more seconds when I set the Section Count to -1 to get the roughing paths.
The gaps observed between Face sections are because the algo generates a Face claim that gets an edge of the mill tangential to all points of the Face OuterWire. The tool mills by its radius past the response envelope/surfaces that I am generating.
The model generated allows bounded face by face control--very atomic--of the Job Model. Next Image, switches to Zig-Zag Outline PocketMode.
4--I implemented the response for BallEndMills along with the SquareMill tool responses I have been working on. It's relatively trivial to work with Square and Ballnose endmills because the normalAt() function provides the basis for each. For Square, the z-component is zeroed. For the Ballnose, an offset in Z of the Mill radius is added so that it is Tool Tip referenced--same as with square...
BTW, I already researched months ago, and Rounded Edge mills will fall out of the same calculation as a combination square and ballnose geometries where the Corner Radius and Flat Radius generate radial offset paths to the OuterWire. I just haven't gotten it done yet.
- Attachments
-
- Dev000.FCStd
- (572.71 KiB) Downloaded 36 times
-
- SquareEndmillMillingToolpath.FCMACRO
- (17.5 KiB) Downloaded 35 times
Re: 3d milling algo
What appeals to me about this scheme is that it leverages existing PathWB tools--and I believe, philosophy--so the added time required to provide current functionality to more geometry is small.
I plan to add more geometry--torus and sphere should be a relatively straight forward add. Sphere as well. Cone I think is like cylinder but gets tricky because the available surface to mill from top depends on cone axis and cone angle.
I think the SurfaceWB may hold key to providing a True surface path generation. I'm also curious to try taking the existing top Feature.Area path generation, and project it onto the bottom Face that I have. I need to look at existing functions, and if the answer isn't there, then I think discretizing the path, and finding the intersection point on the bottom finish surface, and placing a point there, etc...
This is still very primitive. Very limited bounding is in place currently. For example, a mill claim will be generated for Face-A, without regard for incursion into Face-B. Also, inner wires are not yet considered.
I attached the project file and script if anyone cares to check it out.
Best,
Josh
I plan to add more geometry--torus and sphere should be a relatively straight forward add. Sphere as well. Cone I think is like cylinder but gets tricky because the available surface to mill from top depends on cone axis and cone angle.
I think the SurfaceWB may hold key to providing a True surface path generation. I'm also curious to try taking the existing top Feature.Area path generation, and project it onto the bottom Face that I have. I need to look at existing functions, and if the answer isn't there, then I think discretizing the path, and finding the intersection point on the bottom finish surface, and placing a point there, etc...
This is still very primitive. Very limited bounding is in place currently. For example, a mill claim will be generated for Face-A, without regard for incursion into Face-B. Also, inner wires are not yet considered.
I attached the project file and script if anyone cares to check it out.
Best,
Josh
Re: 3d milling algo
I took a first pass at projecting the Top generated Pocket onto the Surface of the ideal finish cut, and it looks very promising. I have a minor bug in there where some extra faces and thus cuts are generated on the model, but otherwise, it looks very encouraging.
Here is with Outline Pocket Mode selected, with 0.5 mm step size, for a 3.175mm square-mill.
I still need to determine how to project upward, bounded by tool envelope, but in short run, coupled with roughing, it would generate milling paths same as usual, but with 3d roughing/finishing...
Here is with Outline Pocket Mode selected, with 0.5 mm step size, for a 3.175mm square-mill.
I still need to determine how to project upward, bounded by tool envelope, but in short run, coupled with roughing, it would generate milling paths same as usual, but with 3d roughing/finishing...
- Attachments
-
- SquareEndmillMillingToolpath.FCMACRO
- (17.85 KiB) Downloaded 33 times
Re: 3d milling algo
Here, I've shifted to a ZigZagOutline, for a 3.175mm BallEndMill. The issue I need to fix is that an extra internal face--violating the upper fillet--is generated, and then paths for it fall out... Tomorrow.
Re: 3d milling algo
I agree - this is looking really good!
Re: 3d milling algo
Thanks for the encouragement guys. I pushed forward today and mostly fixed those extra face issues. I still see an extra section generated on the upper fillet, but it's on the outside at least. I still need to run that down.
@mlampert,I'd take any advice from you. I don't know anything about integrating a script so that it can be used from the GUI. BTW, I think this can be used to take care of the chamfer unable to operate on modeled chamfers you'd mentioned--assuming you have not resolved that already.
I also notice what I believe is a small bug in the PathFeatureArea PocketMode = Outline. My use of that is unconventional because I am using for a center-justified (0mm diameter) mill as opposed to insetting on a face outer wires. So, I set the Tool Radius as low as I can get away with, and am using the step-over distance alone to determine pocket shape.
ZigZagOutline works perfectly. Outline works well, with step-over distance path offsets, until the inner-most area where it is shifted down to the Tool-Radius setting, causing a TON of small paths.
@mlampert,I'd take any advice from you. I don't know anything about integrating a script so that it can be used from the GUI. BTW, I think this can be used to take care of the chamfer unable to operate on modeled chamfers you'd mentioned--assuming you have not resolved that already.
I also notice what I believe is a small bug in the PathFeatureArea PocketMode = Outline. My use of that is unconventional because I am using for a center-justified (0mm diameter) mill as opposed to insetting on a face outer wires. So, I set the Tool Radius as low as I can get away with, and am using the step-over distance alone to determine pocket shape.
ZigZagOutline works perfectly. Outline works well, with step-over distance path offsets, until the inner-most area where it is shifted down to the Tool-Radius setting, causing a TON of small paths.
- Attachments
-
- SquareEndmillMillingToolpath.FCMACRO
- (18.57 KiB) Downloaded 46 times
Last edited by JoshM on Mon Oct 01, 2018 1:08 am, edited 1 time in total.