[fix included] 2DPocket error with activated outline option

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
schnebeck
Posts: 130
Joined: Thu Jun 22, 2017 8:04 pm

[fix included] 2DPocket error with activated outline option

Post by schnebeck »

Hi,

I'm trying to generate a gcode for a little bit complicated part and get errors with the latest appimage.
I try to break this down to isolate the problems. In the attaches project you see a simple 2D pocket OP with activated outline option.
Without everything is fine. But activated I get:
"9Standard_OutOfRange NCollection_Sequence::Value19Standard_OutOfRange NCollection_Sequence::ValueSomething unexpected happened."
and no path.

Bye

Thorsten


OS: KDE neon User Edition 5.19 (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22474 (Git) AppImage
Build type: Release
Branch: master
Hash: a44f8ffd427fa9b23b1f00dbf62d66cd152cd774
Python version: 3.8.5
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: German/Germany (de_DE)
Attachments
pocket2d_outline_error.FCStd
(21.9 KiB) Downloaded 50 times
Last edited by schnebeck on Fri Sep 25, 2020 7:08 pm, edited 1 time in total.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: 2DPocket error with activated outline option

Post by GeneFC »

I got the same error, with a meaningless error message.

If I deselect the "Extensions", then everything seems to work correctly. I don't know what "extensions" do for this shape since there is really no place to "extend".

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22474 (Git)
Build type: Release
Branch: master
Hash: a44f8ffd427fa9b23b1f00dbf62d66cd152cd774
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

Gene
schnebeck
Posts: 130
Joined: Thu Jun 22, 2017 8:04 pm

Re: 2DPocket error with activated outline option

Post by schnebeck »

It extents the outer edges of the pocket. So you do not need to use fancy dress-up stuff to clean a pocket that reaches an outer geometry of the part.
I would like to have this extension config on other Ops, too. If this simply extents a known face or a closed loop of edges building a face, every Op should work with an extended face. E.g. Adaptive Op would profit from this config.

Bye

Thorsten
Last edited by schnebeck on Mon Sep 21, 2020 8:49 pm, edited 2 times in total.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: 2DPocket error with activated outline option

Post by GeneFC »

Sorry. :oops:

I saw the rounded corners and did not look further.

Gene
schnebeck
Posts: 130
Joined: Thu Jun 22, 2017 8:04 pm

Re: 2DPocket error with activated outline option

Post by schnebeck »

Hi,

some more infos:
I extracted the AppImage and activated debug output in PathPocketShape*.py.

This generates some in-process solids that shows an error in generating a valid edge-loop when using the outline option.

Without outline option I see this solid
Screenshot_20200925_181714.png
Screenshot_20200925_181714.png (89.06 KiB) Viewed 1313 times
Its 90° cw rotated but perfectly structured.
Debug log looks like this:

Code: Select all

18:32:18  Free Select
18:32:18  PathPocketShape.DEBUG: ----- areaOpShapes() in PathPocketShape.py
18:32:18  PathPocketShape.DEBUG: Processing... obj.Base
18:32:18  PathPocketShape.DEBUG: type() == Part.Plane
18:32:18  PathPocketShape.DEBUG:   -isVertical()
18:32:18  PathPocketShape.DEBUG: Extension(Model-pocket2d-error, Face8, Wire(9,13,28), 2.50, 0
18:32:18  PathPocketShape.DEBUG: _getEdgeNumbers() -> ['9', '13', '28']
18:32:18  PathPocketShape.DEBUG: PathGeom.combineConnectedShapes shape.BoundBox.ZMin: -25.000000000000004
18:32:18  PathPocketShape.DEBUG: self.horizontal pre-shpZMin: -25.000000000000004
18:32:18  PathPocketShape.DEBUG: self.horizontal post-shpZMin: 25.000000000000004
18:32:18  PathPocketShape.DEBUG: Extent values are strDep: 0.0, finDep: -25.000000000000004,  extrd: Vector (0.0, 0.0, 25.500000000000004)
With outline option I see this:
Screenshot_20200925_181843.png
Screenshot_20200925_181843.png (41.25 KiB) Viewed 1313 times
and got this debug messages:

Code: Select all

18:24:15  Free Select
18:24:15  PathPocketShape.DEBUG: ----- areaOpShapes() in PathPocketShape.py
18:24:15  PathPocketShape.DEBUG: Processing... obj.Base
18:24:15  PathPocketShape.DEBUG: type() == Part.Plane
18:24:15  PathPocketShape.DEBUG:   -isVertical()
18:24:15  PathPocketShape.DEBUG: Extension(Model-pocket2d-error, Face8, Wire(9,13,28), 2.50, 0
18:24:15  PathPocketShape.DEBUG: _getEdgeNumbers() -> ['9', '13', '28']
18:24:15  PathPocketShape.DEBUG: PathGeom.combineConnectedShapes shape.BoundBox.ZMin: -25.000000000000004
18:24:15  PathPocketShape.DEBUG: PathGeom.combineConnectedShapes shape.BoundBox.ZMin: -25.000000000000004
18:24:15  PathPocketShape.DEBUG: self.horizontal pre-shpZMin: -25.000000000000004
18:24:15  PathPocketShape.DEBUG: self.horizontal post-shpZMin: 25.000000000000004
18:24:15  PathPocketShape.DEBUG: Extent values are strDep: 0.0, finDep: -25.000000000000004,  extrd: Vector (0.0, 0.0, 25.500000000000004)
18:24:15  19Standard_OutOfRange NCollection_Sequence::Value19Standard_OutOfRange NCollection_Sequence::ValueSomething unexpected happened. Check project and tool config.
Maybe someone can give a hint howto debug this further.

Bye

Thorsten
schnebeck
Posts: 130
Joined: Thu Jun 22, 2017 8:04 pm

Re: 2DPocket error with activated outline option

Post by schnebeck »

This fixed it for me:

Code: Select all

diff -u master/PathPocketShape.py my/PathPocketShape.py 
--- master/PathPocketShape.py        2020-09-25 20:10:10.976224628 +0200
+++ my/PathPocketShape.py  2020-09-25 20:09:06.771990280 +0200
@@ -648,7 +648,19 @@
                     PathLog.debug('PathGeom.combineConnectedShapes shape.BoundBox.ZMin: {}'.format(shape.BoundBox.ZMin))
                     if obj.UseOutline:
                         wire = TechDraw.findShapeOutline(shape, 1, FreeCAD.Vector(0, 0, 1))
-                        wFace = Part.Face(wire)
+
+                        elist = wire.Edges
+                        mywire = Part.Wire(Part.__sortEdges__(elist))
+
+                        uniqueEdges = []
+                        for edge in mywire.Edges:
+                            if any(PathGeom.edgesMatch(edge, e) for e in uniqueEdges):
+                                continue
+                            uniqueEdges.append(edge)
+                        w = Part.Wire(uniqueEdges)
+
+                        wFace = Part.Face(w)
+
                         if wFace.BoundBox.ZMin != shpZMin:
                             wFace.translate(FreeCAD.Vector(0, 0, shpZMin - wFace.BoundBox.ZMin))
                         self.horizontal.append(wFace)
I do not have any knowledge about this stuff :oops: - this is just copied from other FreeCAD code fragments and tested.
So its just a "works for me"

HTH

Thorsten
Screenshot_20200925_202938.png
Screenshot_20200925_202938.png (74.61 KiB) Viewed 1293 times
schnebeck
Posts: 130
Joined: Thu Jun 22, 2017 8:04 pm

Re: [fix included] 2DPocket error with activated outline option

Post by schnebeck »

sliptonic wrote:ping
Would be nice if someone from the "big guns" takes a look. If this fixes a problem maybe its useful for others too :?:

Bye

Thorsten
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: [fix included] 2DPocket error with activated outline option

Post by mlampert »

Hi Thorsten,

sorry about the late reply - I looked at your change and unfortunately I think there is a bit of hole. Part.sortEdges (AFAIK) does not necessarily return the outline as the first wire - yet the outline is what is required here. It seems to do the trick for your model but that cannot be generalised.

What we should try is figure out why the TechDraw.findOutlineShape does not return the correct outline.
wandererfan wrote: ping
Maybe somebody from the TechDraw team can have a look.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [fix included] 2DPocket error with activated outline option

Post by Kunda1 »

FTFY @mlampert
wandererfan wrote: pinged by pinger macro
:point_up_2:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply