3d Pocket issue

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!
User avatar
JoshM
Posts: 456
Joined: Thu Oct 05, 2017 5:34 pm
Location: New Hampshire

Re: 3d Pocket issue

Post by JoshM »

chrisb wrote: Wed Jul 11, 2018 8:06 am
herbk wrote: Wed Jul 11, 2018 7:39 am again a rounding error?
Possible. I don't get a crash with a diameter of 0.999 or 1.001
I just tried 1mm on my work computer, but I don't see a crash here.
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: 3d Pocket issue

Post by chrisb »

JoshM wrote: Wed Jul 11, 2018 1:11 pm I just tried 1mm on my work computer, but I don't see a crash here.
Can other Linux/Mac/Win users please test?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: 3d Pocket issue

Post by sliptonic »

I get a path generated for most tool sizes (including larger than 5.0) but I also get the crash at 1.0

OS: Linux Mint 18 Sarah
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14059 (Git)
Build type: Unknown
Branch: master
Hash: b54661c09a8a6c289a039d8d0848c08c165e2002
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: 3d Pocket issue

Post by TheMarkster »

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14061 (Git)
Build type: Release
Branch: master
Hash: c4fc02cbcfff975712e977dc08f859fba71ba0ad
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)


I get this error on loading the file:

Code: Select all

Enumeration index -1 is out of range, ignore it
Traceback (most recent call last):
  File "<string>", line 1, in <module>
<type 'exceptions.IOError'>: Cannot get value from invalid enumeration
No crash when setting tool diameter to 1.0, but I get an exception: Unknown C++ Exception.

I take it mode=0 is Absolute, mode=1 is BoundBox, mode=2 is Workplane in the area.makeSections() function below. Just by experimenting if I change mode=0 to mode=1 it seems the C++ exception doesn't happen with tool diameter set to 1.0 for the Pocket_3D operation and a path is formed.

PathAreaOp.py

Code: Select all

  def _buildPathArea(self, obj, baseobject, isHole, start, getsim):
        '''_buildPathArea(obj, baseobject, isHole, start, getsim) ... internal function.'''
        PathLog.track()
        area = Path.Area()
        area.setPlane(PathUtils.makeWorkplane(baseobject))
        area.add(baseobject)

        areaParams = self.areaOpAreaParams(obj, isHole)

        heights = [i for i in self.depthparams]
        PathLog.debug('depths: {}'.format(heights))
        area.setParams(**areaParams)
        obj.AreaParams = str(area.getParams())

        PathLog.debug("Area with params: {}".format(area.getParams()))

        sections = area.makeSections(mode=1, project=self.areaOpUseProjection(obj), heights=heights) #was mode=0
Enumeration: AreaParams.h

Code: Select all

#define AREA_PARAMS_SECTION_EXTRA \
    ((enum,mode,SectionMode,2,"Section offset coordinate mode.\n"\
        "'Absolute' means the absolute Z height (given in SectionOffset) to start slicing.\n"\
        "'BoundBox' means relative Z height to the bounding box of all the children shape.\n"\
        "'Workplane' means relative to workplane, minus SectionOffset.\n"\
        "Note that OCC has trouble getting the minimum bounding box of some solids, particularly\n"\
        "those with non-planar surface. It is recommended to use Workplane to specify the intended\n"\
        "starting z height.\n",(Absolute)(BoundBox)(Workplane)))\
    ((bool,project,Project,false, "The section is produced by normal projecting the outline\n"\
        "of all added shapes to the section plane, instead of slicing."))
This is also interesting. Perhaps by stepping through this bit of code the bug can be pinned down. I don't have a way to debug the C++ code at this time.

(at time of call from python, heights = [11.0,10.0,9.0,8.0,7.0])

Area.cpp

Code: Select all

        for(double z : _heights) {
            switch(mode) {
            case SectionModeAbsolute: {
                gp_Pnt pt(0,0,z);
                z = pt.Transformed(loc).Z(); /*could be here where the exception happens, maybe*/
                break;
            }case SectionModeBoundBox:
                z = zMax - z;
                break;
            case SectionModeWorkplane:
                z = -z;
                break;
            default:
                throw Base::ValueError("invalid section mode");
            }
Post Reply