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

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

Post by realthunder »

sliptonic wrote: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.
I have changed 'Outline=True' behavior. It does proper projection now, so that you can throw in any type of faces (non-workplane-parallel, non-planar, etc) and still get correct result. makeSections() now uses the same code to get projection. The 'project' parameter in makeSections, or 'Project' parameter in Path.Area, is independent with 'Outline' parameter in Path.Area. More specifically, 'project' or 'Project' controls whether you get sliced section, or projected outline sections, and is only effective when you have solid and trying to make section. 'Outline' will have effect if you are not making sections. So by simply setting 'Outline' to True, you'll get a single outline face at the work plane.

I've also somewhat fixed the artifacts problem. The actual cause of this problem is that, previously, projection is done separately on each shape faces. So two faces are projected separately, and then unioned together, causing rounding error. I've fixed that. Now, as long as the two faces are in the same shape/compound, it will be projected together. Faces not in the same compound are still projected separately, because you may add shapes for different operations, like cut, intersect, etc.

In summary, this will give you the correct result without artifacts

Code: Select all

shape = Path.Area(Outline=True).add(Part.makeCompound([face1,face2,face3])).getShape()
Part.show(shape)


I've also fixed a work plane direction problem. For some shapes, like the Cut shape in your file, all faces have reversed OCC orientation for some reason. This causes the auto selected work plane having the wrong normal (0,0,-1), and in turn, causes section error (i.e. wrong section direction, which means setting SectionCount=-1 will give you only one section). I've now forced the normal to point toward the positive axis direction if the selected plane aligns with X, Y or Z plane. This direction problem may also cause projection failure if your manually set a work plane with (0,0,1) direction. It has also been fixed. Please try it out.
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
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

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

Post by sliptonic »

If I get a reference to the lower face in the model (Face14) and do

shape = Path.Area(Outline=True).add(sub).getShape() it works as you describe.

But if I get a reference to the top face (Face13) and do the same thing, I get an error that the face is not planar. However,
DraftGeomUtils.isPlanar(sub) returns True for the same face.

Interestingly, if I select both Face13 and Face14, it works.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

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

Post by realthunder »

sliptonic wrote:But if I get a reference to the top face (Face13) and do the same thing, I get an error that the face is not planar
Could you please show me your exact code? I just tried it and it works. Are you sure you have pulled my latest commit?

Code: Select all

comp = Part.makeCompound(Gui.Selection.getSelectionEx()[0].SubObjects)
Part.show(Path.Area(Outline=True).add(comp).getShape())
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
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

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

Post by sliptonic »

realthunder wrote:
sliptonic wrote:But if I get a reference to the top face (Face13) and do the same thing, I get an error that the face is not planar
Could you please show me your exact code? I just tried it and it works. Are you sure you have pulled my latest commit?

Code: Select all

comp = Part.makeCompound(Gui.Selection.getSelectionEx()[0].SubObjects)
Part.show(Path.Area(Outline=True).add(comp).getShape())
My code is effectively the same as yours. I double checked and I've merged your branch as of: 56a3501

Running your code snippet, I get the error.
snapshot-1-8.png
snapshot-1-8.png (62.87 KiB) Viewed 1289 times
The rest of my FreeCAD info
OS: Linux Mint 18 Sarah
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11043 +22 (Git)
Build type: Unknown
Branch: feature/PathAreaOps
Hash: 58f106023066cbfbafbe43432b242981a7dee6dc
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

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

Post by realthunder »

sliptonic wrote:OCC version: 6.8.0.oce-0.17
Could you please try with OpenCascade official version. That's the only difference I can tell. I am building with OCE right now. Anyway, I think FC 0.17 is moving to OCCT 7, so you might as well switch to the official library now.
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
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

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

Post by sliptonic »

Yes, that did it. Resuming my testing... So far, looks good. :D
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

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

Post by realthunder »

realthunder wrote:
sliptonic wrote:OCC version: 6.8.0.oce-0.17
Could you please try with OpenCascade official version. That's the only difference I can tell. I am building with OCE right now. Anyway, I think FC 0.17 is moving to OCCT 7, so you might as well switch to the official library now.
Yes, it is OCE problem. And I've just fixed it. Please try. I'd still strongly suggest you to switch to OCCT 7. It has improved on a lot of other things.
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
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

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

Post by sliptonic »

confirmed fixed with occ 6.8.

I'm just about done with re-working the PathMillFace and PathContour operations to use Path.Area exclusively. I'm sure I've got plenty of bugs but I'd like to have people test my branch. Unless you've got more coming for Area, how about merging your current stuff to master?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

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

Post by realthunder »

sliptonic wrote:how about merging your current stuff to master?
Sure, PR submitted.
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
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

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

Post by sliptonic »

Offset seems to be giving me 2X what I expect. What am I doing wrong here?
I would expect the boundbox to be 15 ( 2 * 2.5 + 10) but it returning 20.

Code: Select all

import Path
import Part

partshape = Part.makeBox(10,10,10)
Part.show(partshape)

profile = Path.Area()
profile.setPlane(Part.makeCircle(10))
profile.add(partshape)

profileparams = {'Fill': 0, 'Coplanar': 0}
profileparams['Offset'] = 2.5
profile.setParams(**profileparams)

sections = profile.makeSections(mode=0, project=True, heights=[0.0,1.0,2.0])
shapelist = [sec.getShape() for sec in sections]
x = Part.makeCompound(shapelist)
print x.BoundBox.XLength
Part.show(x)
Post Reply