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

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

Postby realthunder » Fri May 05, 2017 6:28 pm

realthunder wrote:
sliptonic wrote:Does this have anything to do with why the ZigZag pattern stopped working? I can get pocket paths out of offset but not zigzag.
Not likely. Most likely due to the new patterns added. I'll look into that shortly.
Okay, fixed in my PathArea branch. It is a silly bug. The orientation may take a while. It is much more complex.
Try Assembly3 (latest version 0.10.2) along 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
Posts: 1172
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Sun May 07, 2017 8:36 pm

sliptonic wrote:Working more with Projection and sections I hit some weirdness.
I've submit a new fix. Please test the projection as well as the path orientation setting. Now orientation can only be 0=Normal, 1=Reversed, as I mentioned in my previous post.

I have also renamed the original 'clearance' parameter in fromShapes to 'resume_height' to avoid confusion. Resume height is the relative Z height above the next Z layer height when return from retraction. This can usually be set to step down value. However, Path.fromShapes does not have knowledge of step down, hence you need to manually specify this parameter here. This shall solve your retraction problem.
Try Assembly3 (latest version 0.10.2) along 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
sliptonic
Posts: 1560
Joined: Tue Oct 25, 2011 10:46 pm

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

Postby sliptonic » Mon May 08, 2017 9:06 pm

Results from projects and orientation are looking very good now. No issues to report.

I'm trying to use the projection mode more consistently but there's something that TechDraw does that I can't figure out how to do with Path.Area:

With TechDraw, I can select several faces, make a compound, and then get the shapeoutline of the compound. But with Path.Area, I can't seem to section a single face parallel to the XY plane. I just get an empty projection. Is this possible?
realthunder
Posts: 1172
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Tue May 09, 2017 6:32 am

sliptonic wrote:Results from projects and orientation are looking very good now. No issues to report.

I'm trying to use the projection mode more consistently but there's something that TechDraw does that I can't figure out how to do with Path.Area:

With TechDraw, I can select several faces, make a compound, and then get the shapeoutline of the compound. But with Path.Area, I can't seem to section a single face parallel to the XY plane. I just get an empty projection. Is this possible?
If all the faces are in the same plane, then no need for the expensive projection operation. Just union the face and then remove all inner wires will do. I've added a new parameter called 'Outline'. Set it to true to get what you want.

Code: Select all

# union all faces, and then remove all inner wires
area = Path.Area(Outline=true).add([face1, face2, face3])
Part.show(area.getShape())

The difference between 'Outline' and 'Project' is that 'Outline' deals with 2D faces only, while 'Project' deals with 3D solid. If the faces are at different plane, then you have to either manually move the faces to the same plane or manually create compound and do section with projection.
Try Assembly3 (latest version 0.10.2) along 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
sliptonic
Posts: 1560
Joined: Tue Oct 25, 2011 10:46 pm

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

Postby sliptonic » Tue May 09, 2017 1:15 pm

realthunder wrote: The difference between 'Outline' and 'Project' is that 'Outline' deals with 2D faces only, while 'Project' deals with 3D solid. If the faces are at different plane, then you have to either manually move the faces to the same plane or manually create compound and do section with projection.
Nice! I'll try it. In my example, the faces were on different planes. I did exactly what you described but always got an empty list when sectioning the compound. I'll try again and attach a sample file if I get the same results.
User avatar
sliptonic
Posts: 1560
Joined: Tue Oct 25, 2011 10:46 pm

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

Postby sliptonic » Tue May 09, 2017 6:30 pm

My problem with empty section is fixed - I was missing the coplanar check.

Results from outline project using a compound of faces are still showing a bug though.
I'm attaching a file, projectionbug.fcstd.
Cut002 is the original shape.
I selected Face13 and Face14 and ran this test macro:

Code: Select all

import Path
import PathScripts.PathUtils as PU
sel = Gui.Selection.getSelectionEx()[0]
obj = sel.Object

profileparams = {'Fill': 1, 'Coplanar' : 0}

c = Part.makeCompound(sel.SubObjects)
r = Path.Area(Project=True).add(c)
r.setPlane(Part.makeCircle(10))

r.setParams(**profileparams)

#env = PU.getEnvelope(c, 10)
#Part.show(r.getShape(-1, True))
sec = r.makeSections(heights=[0.0], project=True)
if len(sec) == 0:
    print ('no section')
    Part.show(r.getShape(-1, True))
else:
    print ('section')
    sec[0].getShape(-1, rebuild=True)

area = Path.Area(Fill=1, Coplanar=0).add(obj.Shape)
area.setPlane(Part.makeCircle(10))
Part.show(area.makeSections(heights=[1.0], project=True)[0].getShape(rebuild=True))
shapeprojection is the overall silhouette of the whole object. It's perfect.
faceprojection is the projection of a compound from the two faces. You'll see the intersection lines don't meet correctly.
faceprojectionOutline is the projection with Outline=True. The problem is reduced but still present.
Attachments
projectionbug.fcstd
(101.69 KiB) Downloaded 9 times
realthunder
Posts: 1172
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Tue May 09, 2017 9:05 pm

sliptonic wrote:Results from outline project using a compound of faces are still showing a bug though.
I was not clear in my previous post. When I said make a compound, I actually mean to make a compound of face and then extrude a solid. Because makeSection is supposed to only work with solid. I am surprised that you even get any result for face compound. And you have just stumbled upon an unexpected usage of Path.Area.

Here is what actually happened. Section won't work when there is no solid. So Area just do normal operation on all faces. When you set Coplanar=0, it will not check face plane, and simply convert face wires to 2D by ignore the Z value. That is actually some kind of projection! So, you don't need to call makeSections at all in this use case. The artifacts you see is due to those faces having some near coincident edges. If you enlarge the shape produced, you'll see the artifacts are actually small holes. So, by adding Outline=True, you can remove those holes.
Screenshot from 2017-05-10 03-49-27.png
Screenshot from 2017-05-10 03-49-27.png (2.57 KiB) Viewed 596 times
After setting Outline=True
Screenshot from 2017-05-10 03-49-37.png
Screenshot from 2017-05-10 03-49-37.png (1.71 KiB) Viewed 596 times
So in summary. Here is what you can do to get face outlines

Code: Select all

outline = Path.Area(Coplanar=0, Outline=True).add([face1, face2, face3]).getShape()
One more thing, I see lots of getShape(rebuild=True) and getShape(-1, rebuild=True). You normally don't need to do that. Simple getShape() will do in most cases. And only use getShape(index) to get individual section if you doing section with SectionCount parameter in Path.Area instead of calling makeSections, You almost never need to set rebuild=True, I added that for debugging purpose. You'll be wasting time to rebuild in most cases.
Try Assembly3 (latest version 0.10.2) along 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
sliptonic
Posts: 1560
Joined: Tue Oct 25, 2011 10:46 pm

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

Postby sliptonic » Tue May 09, 2017 9:40 pm

realthunder wrote:
So in summary. Here is what you can do to get face outlines

Code: Select all

outline = Path.Area(Coplanar=0, Outline=True).add([face1, face2, face3]).getShape()
O.k. Makes sense but those tiny cuts in the second screenshot are still a problem for me. For instance in a path that isn't offset (for example a laser cutting 'on the line' the beam will be spending more time than it should in that corner delivering too much heat. I don't get those cuts in the TechDraw method. Is that a tolerance thing?
One more thing, I see lots of getShape(rebuild=True) and getShape(-1, rebuild=True). You normally don't need to do that. Simple getShape() will do in most cases. And only use getShape(index) to get individual section if you doing section with SectionCount parameter in Path.Area instead of calling makeSections, You almost never need to set rebuild=True, I added that for debugging purpose. You'll be wasting time to rebuild in most cases.
Cool. I started adding the rebuild=True when I was seeing the projection orientation weirdness. I won't use it in my production code.
realthunder
Posts: 1172
Joined: Tue Jan 03, 2017 10:55 am

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

Postby realthunder » Wed May 10, 2017 2:59 am

sliptonic wrote:O.k. Makes sense but those tiny cuts in the second screenshot are still a problem for me. For instance in a path that isn't offset (for example a laser cutting 'on the line' the beam will be spending more time than it should in that corner delivering too much heat. I don't get those cuts in the TechDraw method. Is that a tolerance thing?
If you align those two faces together, you can see the gap.
Screenshot from 2017-05-10 10-54-26.png
Screenshot from 2017-05-10 10-54-26.png (3.63 KiB) Viewed 579 times
In this cases, you either need to fix the model itself, or you can use the trick to do a slight expansion offset, and then a second shrink offset to remove those gaps.

But, I am curious how TechDraw handles it. Could you please post your TechDraw code?
Try Assembly3 (latest version 0.10.2) along 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
sliptonic
Posts: 1560
Joined: Tue Oct 25, 2011 10:46 pm

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

Postby sliptonic » Wed May 10, 2017 3:52 am

realthunder wrote:If you align those two faces together, you can see the gap.
In this cases, you either need to fix the model itself, or you can use the trick to do a slight expansion offset, and then a second shrink offset to remove those gaps.

But, I am curious how TechDraw handles it. Could you please post your TechDraw code?
Huh. That's weird. It's not in the model which is just made from stacked and cut cylinders. The gap occurs with the selected faces compounded together. Must be an OCC/tolerance/rounding thing.

Here's how I call the TechDraw function to generate the perimeter wire from the selected faces.

Code: Select all

sel = Gui.Selection.getSelectionEx()[0]
Part.show(TechDraw.findShapeOutline(Part.makeCompound(sel.SubObjects), 1, FreeCAD.Vector(0,0,1)))