Part macros adding cutouts and fillets for better milling and lasercut

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Part macros adding cutouts and fillets for better milling and lasercut

Post by openfablab »

Hello! :)

Sometimes I need to cut huge volumes of complex sheet metal parts with laser of CNC mill. These technologies are not good with sharp corners, both internal and external. So I have to manually add holes and fillets. But it is boring! And there are thousands! :shock: Please, help me to automate it with macros. I know python and FreeCAD scripting basics, but use it rarely and not professionally.

I hope this macros will be useful for many others who work with CNC mill and lasercut.
workflow.png
workflow.png (79.14 KiB) Viewed 2241 times
The process (after selection of face of the part) can looks like this:

1. Get selected face

Code: Select all

def select_face():
    try:
        if len(Gui.Selection.getSelectionEx())==0:
            print "No face selected! Please select a face."
            return -1
        if len(Gui.Selection.getSelectionEx()[0].SubObjects)>1:
            print "Multiple faces selected! Please select ONE face." #Multiple selection to be added later
            return -1
        if Gui.Selection.getSelectionEx()[0].SubObjects[0].ShapeType <> 'Face':
            print "Selection is not a Face! Please select a Face."
            return -1
        if Gui.Selection.getSelectionEx()[0].SubObjects[0].curvatureAt(0,0)<>(0,0):
            print "This process work only for flat faces!"
            return -1          
        return Gui.Selection.getSelectionEx()[0].SubObjects[0]
    except:
        print "Face is not selected! Please select a Face."
        return -1
2. Make sketch on this face
3. Make list of internal corners (common wires (ortogonal to selected face) of two non-tangent faces)
4. Make circles with R radius on the sketch over these corners (not directly over corners, but with corner point layind on circle)
5. Pocket through all
6. Recognize work face of new appeared part (may be by normal)
7. Make list of all corners and make them fillets with R radius.
8. Change colour of the part (optionally, to see processed parts)
Last edited by openfablab on Thu Jan 26, 2017 4:58 pm, edited 1 time in total.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by sliptonic »

I would suggest that you shouldn't be adding these to your design. What if you change the type of tool you use to cut the parts? You will have to redesign your parts to account for the different tool.

In the Path workbench (for generating gcode) we add the additional moves needed to account for inside corners. See: https://youtu.be/Ix_HfaL0TxU
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by openfablab »

sliptonic wrote:I would suggest that you shouldn't be adding these to your design. What if you change the type of tool you use to cut the parts? You will have to redesign your parts to account for the different tool.

In the Path workbench (for generating gcode) we add the additional moves needed to account for inside corners. See: https://youtu.be/Ix_HfaL0TxU
You are right, this tool-specific work should be part of path generation, not part modelling. Could path trajectories be exported to DXF instead of G-code?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by DeepSOIC »

How is this operation on concave edges is called? Something like "counterfillet" maybe...
I want that to be a feature like fillet. I often want it for 3d printing, and it's quite a pain to do manually.
hole for hexagonal rod.png
hole for hexagonal rod.png (170.77 KiB) Viewed 2209 times
For example. In this project, I made a hole for a hexagonal rod. Because printer decelerates/accelerates at sharp corners, and because extruder has some "inertia" and doesn't cease to extrude plastic immediately to follow the speed profile, a bit of blobbiness happens at corners. This may cause the rod not fitting. I often add such indented fillets to avoid the problem.

EDIT: added another picture
counterfillet.png
counterfillet.png (54.5 KiB) Viewed 2209 times
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by mlampert »

DeepSOIC wrote:How is this operation on concave edges is called? Something like "counterfillet" maybe...
I want that to be a feature like fillet. I often want it for 3d printing, and it's quite a pain to do manually.
It's called a "dogbone" the way you use it, and then there are also T-bones, same idea just different cutout. Please checkout sliptonic's video, it's pretty good and should show you how to use the feature in Path.

What is your (desired) output format? Is it also DXF?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by DeepSOIC »

mlampert wrote:It's called a "dogbone" the way you use it, and then there are also T-bones, same idea just different cutout. Please checkout sliptonic's video, it's pretty good and should show you how to use the feature in Path.

What is your (desired) output format? Is it also DXF?
Thanks for terms!
My desired output format is 3d geometry (B-Rep in FC, then STL, then slice into g-code with slic3r and send to printer).

Hopefully I will get busy with this some day. Not today :mrgreen:
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by sliptonic »

openfablab wrote:
sliptonic wrote:I would suggest that you shouldn't be adding these to your design. What if you change the type of tool you use to cut the parts? You will have to redesign your parts to account for the different tool.

In the Path workbench (for generating gcode) we add the additional moves needed to account for inside corners. See: https://youtu.be/Ix_HfaL0TxU
You are right, this tool-specific work should be part of path generation, not part modelling. Could path trajectories be exported to DXF instead of G-code?
Probably. You'd have to convert the path to wires first but that's easy:

Code: Select all

path = myObject.Path
points = [c.Placement.Base for c in path.Commands]
wire = Part.makePolygon(points)
Part.show(wire)
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by DeepSOIC »

sliptonic wrote:I would suggest that you shouldn't be adding these to your design. What if you change the type of tool you use to cut the parts? You will have to redesign your parts to account for the different tool.
I would say, it depends on situation. If you design in the dogbones, you will be able to mill the part with the mill of the size it was designed for, as well as with a smaller mill, with the exact same result regardless of the tool.

Also, one may want the actual shape of the result as a model for FEM purposes. Dogbones can affect the strength of the result (can decrease as well as increase strength, with possibly a huge impact on fatigue performance).
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by sliptonic »

DeepSOIC wrote:I would say, it depends on situation. If you design in the dogbones, you will be able to mill the part with the mill of the size it was designed for, as well as with a smaller mill, with the exact same result regardless of the tool.

Also, one may want the actual shape of the result as a model for FEM purposes. Dogbones can affect the strength of the result (can decrease as well as increase strength, with possibly a huge impact on fatigue performance).
fair enough. I hadn't considered the FEM angle.
User avatar
openfablab
Posts: 62
Joined: Wed Nov 02, 2016 4:42 pm
Contact:

Re: Part macros adding cutouts and fillets for better milling and lasercut

Post by openfablab »

Thus it make sense to have Dogbone tools in both PartDesign (on selected corners, just like Fillet or Chamfer) and Path (automatic at all relevant corners) modules.
Post Reply