Path.Area: Welcome, to the new era!

Here's the place for discussion related to CAM/CNC and the development of the Path module.
realthunder
Posts: 109
Joined: Tue Jan 03, 2017 10:55 am

Path.Area: Welcome, to the new era!

Postby realthunder » Fri Jan 27, 2017 9:40 am

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 800 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 800 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 800 times
Last edited by realthunder on Wed Feb 01, 2017 9:41 am, edited 2 times in total.
cox
Posts: 912
Joined: Wed Nov 26, 2014 11:37 pm

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

Postby cox » Fri Jan 27, 2017 9:52 am

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

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

Postby realthunder » Fri Jan 27, 2017 9:56 am

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

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

Postby realthunder » Fri Jan 27, 2017 10:04 am

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 790 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 790 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 790 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 790 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 790 times
User avatar
bill
Posts: 155
Joined: Fri Jan 09, 2015 9:25 pm

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

Postby bill » Fri Jan 27, 2017 1:39 pm

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

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

Postby chrisb » Fri Jan 27, 2017 7:09 pm

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

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

Postby realthunder » Sat Jan 28, 2017 4:57 pm

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

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

Postby realthunder » Sat Jan 28, 2017 5:02 pm

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.
User avatar
yorik
Site Admin
Posts: 8562
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

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

Postby yorik » Sat Jan 28, 2017 7:32 pm

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

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

Postby chrisb » Sun Jan 29, 2017 12:49 am

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: ).