Path.Area: Welcome, to the new era!

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
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Path.Area: Welcome, to the new era!

Post by realthunder »

How do you like the title? A bit dramatic, right? No. Let me assure you that it is in fact an understatement to what I'm about to present to you, the killer feature of Path Mod.

A few days ago, I submit a pull request adding Path.Area, and Path::FeatureArea. The feature is supposed to be used to generate wires that can be later used to generate path. Because it can't generate path at that time, there is debate about how to incorporate the feature into current Path Mod.

With my latest push, the debate is over, which is why I started this new thread. Introducing the all powerfully Path.fromShapes() function. It can properly convert any number of shapes into path, with optimized travel distance, and ordering based on each wires Z height. It internally uses Path.Area, which is my FC wrapper for libarea, of course.

In case you want to try out my branch, its here

Now, prepare to be amazed!

Code: Select all

App.newDocument('test')

workpiece = App.ActiveDocument.addObject('Part::Feature','workpiece')
workpiece.Shape = Part.makeBox(10,10,10)
workpiece.ViewObject.Transparency = 70

model = App.ActiveDocument.addObject('Part::Feature','model')
model.Shape = Part.makeBox(10,10,8).cut(Part.makeCylinder(3,10,App.Vector(5,5,1)))
model.ViewObject.Transparency = 50

This gives us the model and workpiece
Screenshot from 2017-01-27 16-48-14.png
Screenshot from 2017-01-27 16-48-14.png (200.8 KiB) Viewed 7132 times

Code: Select all

import Path

# This is the profiling job
profile = Path.Area(Offset=1,SectionCount=-1)
profile.add(workpiece.Shape)
Path.show(Path.fromShapes(profile.getShape()))

# This is the pocketing job
pocket = Path.Area(PocketMode=4,SectionCount=-1)
pocket.add((workpiece.Shape,model.Shape),op=1)
Path.show(Path.fromShapes(pocket.getShape()))

That's it. You get the profile and pocket path.
Screenshot from 2017-01-27 16-48-56.png
Screenshot from 2017-01-27 16-48-56.png (227.38 KiB) Viewed 7132 times
Here, I just show you with the minimum code necessary. There are tons of settings you can play with for fine tuning. Make no mistake, Path.Area is for developers. Nothing is hardcoded. Every option is exposed as a parameter.

Now, let's do some tunning.

Code: Select all

App.newDocument('test')

# Smaller tool, SectionOffset is the first layer depth
profile = Path.Area(Offset=0.5,SectionCount=-1,SectionOffset=0.5)
profile.add(workpiece.Shape)

# specify retraction height, and retraction return clearance
Path.show(Path.fromShapes(profile.getShape(),height=11,clearance=0.5))

# Smaller tool, fine tuning stepdown to get an accurate model top surface
pocket = Path.Area(PocketMode=4,SectionCount=-1,ToolRadius=0.5,SectionOffset=0.5,Stepdown=0.499)
pocket.add((workpiece.Shape,model.Shape),op=1)

# Choose a start position to minimize travel distance. Specify retraction threshold to keep tool down
Path.show(Path.fromShapes(pocket.getShape(),start=App.Vector(10),height=11,clearance=0.5,threshold=1))

Screenshot from 2017-01-27 16-50-21.png
Screenshot from 2017-01-27 16-50-21.png (229.97 KiB) Viewed 7132 times
Last edited by realthunder on Wed Feb 01, 2017 9:41 am, edited 2 times in total.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Path.Area: Welcom, to the new era!

Post by cox »

wow, this looks amazing :D
Need help? Feel free to ask, but please read the guidelines first
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Path.Area: Welcom, to the new era!

Post by realthunder »

Pretty amazing, isn't it? However, you haven't seen half of it yet. With the new script tool and GUI features here, you can do things you can't imagine before. Heck, you may be able to do things even I can't imagine right now. Let me show you some example. Let's make tags, freestyle!

Code: Select all

App.newDocument('test')

workpiece = App.ActiveDocument.addObject('Part::Feature','workpiece')
workpiece.Shape = Part.makeBox(10,10,10)
workpiece.ViewObject.Transparency = 70

profile = App.ActiveDocument.addObject('Path::FeatureArea','profile')
profile.Sources = [workpiece]
profile.setParams(Fill=0,Offset=0.5,SectionCount=-1,SectionOffset=0.5)
bottom = App.ActiveDocument.addObject('Path::FeatureAreaView', 'bottom')
bottom.Source = profile
bottom.SectionIndex=10
App.ActiveDocument.recompute()

Screenshot from 2017-01-27 17-01-20.png
Screenshot from 2017-01-27 17-01-20.png (220.41 KiB) Viewed 7124 times
This makes use of the Path::FeatureAreaView I newly added. It shows a part of its child FeatureArea's sections. In this case, it shows the last section. Select two edges, and go to Sketch workbench, and make a new sketch, and draw some tags,
Screenshot from 2017-01-27 17-01-07.png
Screenshot from 2017-01-27 17-01-07.png (250.53 KiB) Viewed 7124 times
First select 'bottom' and then the new sketch, go to Path workbench, and click 'Create a feature area' in the toolbar,
Screenshot from 2017-01-27 17-01-53.png
Screenshot from 2017-01-27 17-01-53.png (201.05 KiB) Viewed 7124 times
The default operation is union. Lets change to Difference
Screenshot from 2017-01-27 17-02-29.png
Screenshot from 2017-01-27 17-02-29.png (214.4 KiB) Viewed 7124 times
This is still not what we want. Doing wire operation is not that straight forward with ClipperLib. Toggle 'Explode' to True, finally, we get the wires properly cut.
Screenshot from 2017-01-27 17-02-43.png
Screenshot from 2017-01-27 17-02-43.png (255.26 KiB) Viewed 7124 times
Now, simply select this feature area in tree view, and click 'Create shape from path' in the toolbar to get the path. This reworked Path::FeatureShape takes full advantage of the new Path.fromShapes. So you can simply drag more shapes into it, and it will assemble the path with optimization and everything. You can also tune the settings by changing its various properties.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Path.Area: Welcom, to the new era!

Post by realthunder »

I am not done yet! Basically, with the latest toolset, you can treat any wires as path. You can convert any wires (or faces) into sketch with my latest enhanced Draft.makeSketch, and simply use Path.FeatureShape to generate path directly from sketch! You can manually modify the sketch to see path change in realtime!

For example, you can turn this pocket wires
Screenshot from 2017-01-27 17-04-51.png
Screenshot from 2017-01-27 17-04-51.png (226.22 KiB) Viewed 7122 times
into this sketch
Screenshot from 2017-01-27 17-04-59.png
Screenshot from 2017-01-27 17-04-59.png (256.48 KiB) Viewed 7122 times
and create path directly from it
Screenshot from 2017-01-27 17-05-20.png
Screenshot from 2017-01-27 17-05-20.png (229.59 KiB) Viewed 7122 times
To see what heavy lifting has been done with the new Path.fromShapes, this is a PCB isolation routing with two offset passes, without optimization.
Screenshot from 2017-01-27 17-09-46.png
Screenshot from 2017-01-27 17-09-46.png (233.43 KiB) Viewed 7122 times
Now, with optimization
Screenshot from 2017-01-27 17-09-55.png
Screenshot from 2017-01-27 17-09-55.png (216.84 KiB) Viewed 7122 times
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
bill
Posts: 376
Joined: Fri Jan 09, 2015 9:25 pm

Re: Path.Area: Welcom, to the new era!

Post by bill »

Thats what Im talkin about! Lookin good!
Can you toggle/hide rapids so only cuts show?
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: Path.Area: Welcom, to the new era!

Post by chrisb »

Impressive.
I currently have two questions:
- Do you plan an integration with the concept of jobs and the tool selection as they exists now?
- In the other post you said, that circles can only be approximated, does this mean that no G2 or G3 commands are created in GCode?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Path.Area: Welcom, to the new era!

Post by realthunder »

bill wrote:Thats what Im talkin about! Lookin good!
Can you toggle/hide rapids so only cuts show?
Well, the Path::FeatureShape is the one showing all the green and red path, which is generated from its children shape. So just hide the feature, and show its children shape. The wires in the children defines the path
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Path.Area: Welcom, to the new era!

Post by realthunder »

chrisb wrote:Impressive.
I currently have two questions:
- Do you plan an integration with the concept of jobs and the tool selection as they exists now?
- In the other post you said, that circles can only be approximated, does this mean that no G2 or G3 commands are created in GCode?
- Yes, of course. Path::FeatureShape is a quick demo of Path.fromShapes script function. I am waiting for the Path developer's response here.
- The path generation uses the same libarea as the existing Path scripts. So, you will get all the G2 and G3 move as usual. What libarea does is to discretize all curves into line segments, do some processing, and fit back with arcs. The fitting of course is not perfect, but you can control the accuracy by tuning various parameters I exposed here.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Path.Area: Welcom, to the new era!

Post by yorik »

Very impressive work, realthunder! Thanks for listening to us and adapting your work! This looks phenomenal!
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: Path.Area: Welcom, to the new era!

Post by chrisb »

realthunder wrote: - Yes, of course. Path::FeatureShape is a quick demo of Path.fromShapes script function. I am waiting for the Path developer's response here.
- The path generation uses the same libarea as the existing Path scripts. So, you will get all the G2 and G3 move as usual. What libarea does is to discretize all curves into line segments, do some processing, and fit back with arcs. The fitting of course is not perfect, but you can control the accuracy by tuning various parameters I exposed here.
Thank you, made my day! (Well rather my night :lol: ).
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply