[BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

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!
Lupin
Posts: 76
Joined: Sat Mar 13, 2021 10:55 am

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by Lupin »

Syres wrote: Thu Dec 30, 2021 3:30 pm it should have been specific in stating Model-Body > Base > Placement > Position X/Y
The problem is not with the placement of the of the model itself, but where the CNC path ends up. That's why it is a little bit hard to describe. I did say that the location of stepdown is important in the original post though. This means that just changing to a different tool diameter can lead to (or remove) a buggy path depending on where the path ends up to be. The same is true for the extra offset that can be specified for a profile operation. If it makes the profile's CNC path start fall onto an axis, you get the buggy path.
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by onekk »

The problem is that OCC is not managing Path entities that usually relies when creating a path on LibArea, but the real internal working is not clear to me actually.

suppose "profile" and "pockets" are calculated by "libArea" for what I know and from the description in:

https://github.com/danielfalck/libarea


"3d operation" are using "OpenCamLib"

https://wiki.freecadweb.org/OpenCamLib

There are some discussion in this forum about some improvement, and standardization, modularisation of the code base, sadly there are no "in deep explanation" on how things are calculated (how path are calculated in the code) around, or maybe I have missed something.

EDIT:

Some analysis lead me to find this in:

https://github.com/FreeCAD/FreeCAD/blob ... hAreaOp.py

around line 225

Code: Select all

        if self.endVector is not None:
            pathParams['start'] = self.endVector
        elif PathOp.FeatureStartPoint & self.opFeatures(obj) and obj.UseStartPoint:
            pathParams['start'] = obj.StartPoint

and in around line 271

Code: Select all


                if self.endVector is None:
                    V = hWire.Wires[0].Vertexes
                    lv = len(V) - 1
                    pathParams['start'] = FreeCAD.Vector(V[0].X, V[0].Y, V[0].Z)
                    if obj.Direction == 'CCW':
                        pathParams['start'] = FreeCAD.Vector(V[lv].X, V[lv].Y, V[lv].Z)
                else:
                    pathParams['start'] = self.endVector
But as usual without some intervention of @sliptonic these are only suppositions, even if these are the real point where the start point is set is a mere suppostion, as it is difficult to follow the workflow of Path creation.

Some information could be guessed from Getting Path from Shape in wiki page:

https://wiki.freecadweb.org/Path_scripting

But in this case is it not clear if the Path obtained is simply a path derived from the wire, it seems not taking in account tool diameter so it is more an engraving path than a profile path.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by GeneFC »

I believe LibArea was replaced several years ago with PathArea.

Gene
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by Russ4262 »

Evening,
I put in a Python fix for this, PR #5343, Path: Fix open edge zero value start point.
Lupin wrote: Thu Dec 30, 2021 4:03 pm ...
Thanks for reporting this bug!

If some of the C++ coders want to fix this upstream, please feel free. The proposed PR fixes this in the Python, in the PathArea module in the _buildProfileOpenEdges() method.

Thanks,
Russell
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by agren »

I took a look at the C++ code and made, what I believe is, a fix here (description in the commit message). It tries to fix the root cause of the issue. But since it changes the behavior of Path.fromShapes and toPath it's hard to know what its effects on other operations are. The nice thing about Russ' fix is that it's very localized to the open edge code.

I would be grateful if someone with more experience with the FreeCAD code could take a look at and comment on my suggested fix.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: [BUG] Profile with stepdown buggs out when CNC path startpoint is on x=0 or y=0

Post by Russ4262 »

agren wrote: Sun Feb 13, 2022 11:18 am I took a look at the C++ code and made, what I believe is, a fix here (description in the commit message). ...
Evening.
Thanks for taking a look at the C++, the source of the bug. I am completely in favor of fixing this in the C++ rather than on the python side. Unfortunately, my C++ skills are almost null, apart from the zero knowledge I have of the C++ source code for FreeCAD. I also ask that those comfortable with the C++ source take a look and review your proposed fix.

Great work!
Russell
Post Reply