Pocket path generated only on face depth if object is reversed or origin moved

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!
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by GeneFC »

umill wrote: Sat Sep 12, 2020 1:46 am for the python files are all changes to the source loaded if we just restart Freecad?
The ordinary *.py files are automatically compiled into *.pyc files by FreeCAD. Those binary files are checked at every load to see if they still match the text-based *.py source files. If so, the existing *.pyc files are used. If not, new compilations are performed.

It all works automatically.

Just for completeness, there are a few *.pyd files that are created only during a full C++, Cmake, etc, build. You generally do not need to worry about those.

I believe it is also possible to reload some Python files even without restarting FreeCAD, but I am not sure this is universal. I always restart.

Gene
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by Syres »

Russ4262 wrote: Sat Sep 12, 2020 6:09 am PR #3862: [Path] PocketShape - fix improper path generation
Morning Russ, I tried your PR on my failing model with the below build but unfortunately it's not fixed this issue. I thought it best to attach the model to assist you in tracking down the code causing the problem. The variable shpZMin seems to be in my case positive 10mm when it should be negative 10mm with regard to ProblemPocket operation. So maybe the IsFaceUp function isn't always giving the correct output and therefore the depth is being flipped when it shouldn't, just a suggestion?

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22366 (Git)
Build type: Release
Branch: master
Hash: 34c11fcc63efa2fc72cbc74c75c76e9f19d5c84c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Attachments
SolidworksExamPiece_NB.FCStd
(126.28 KiB) Downloaded 25 times
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by Russ4262 »

Syres wrote: Sat Sep 12, 2020 7:59 am ... So maybe the IsFaceUp function isn't always giving the correct output and therefore the depth is being flipped when it shouldn't, just a suggestion?
Thank for testing and feedback. The PR only fixed part of the issue. Your suggestion appears correct. I have just updated the PR with what appears to be a true fix based on your part shared earlier in this thread. TIA for additional testing. I apologize for the inconvenience. My code was the source of the error.

Have a great week.
falviani
Posts: 250
Joined: Tue May 07, 2019 8:49 pm

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by falviani »

Hi,

My setup:
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22411 (Git)
Build type: Release
Branch: master
Hash: d4519d5aec15bc08f029da5ed15410a494b57b2c
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)
[This was built this morning from the very latest source]

I have a problem which might be related. I have a simple design where I want to cut a number of pockets, using a 2mm step to a depth of -12.7mm (1/2"). It is actually a top and bottom piece treated as a single piece for the purposes of milling so the cuts are perfectly aligned.

The problem is that the generated code immediately plunges to 13.2mm. I have attached the design file and the generated gcode (changed the extension to .txt so I could attach it). Could somebody tell me 1) If this is a bug or I have a value incorrectly set, and 2) If it is a bug, is there any idea when it might be fixed.

Thanks in advance,
Frank
Attachments
SprayPaintRack.txt
(38.57 KiB) Downloaded 23 times
SprayPaintRack.FCStd
(100.25 KiB) Downloaded 29 times
umill
Posts: 12
Joined: Tue Feb 11, 2020 4:32 pm

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by umill »

Thank you Gene for the detailed explanation. I also noticed if I am using the compiled version of FreeCad I needed to build PathScripts target to copy over the pulled python files from my source directory into the build directory.

Thank you Russ and Syres for the swift fix. I pulled PR#38622 and it has done the job for my attached test part.

Hi falviani, yes this is a bug and in order to apply Russ' patch you need to pull the branch pr/3862. I use Github desktop and I did this by going to branches tab> pull requests and selecting [Path] PocketShape -fix impromper path generation which is right at the top of the list at the moment. This generates a local pr/3862 branch which you can then build the PathScripts target to copy over to your build directory.
Attachments
freecad-pocket-test.FCStd
(51.48 KiB) Downloaded 21 times
falviani
Posts: 250
Joined: Tue May 07, 2019 8:49 pm

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by falviani »

Hi umill,

I always use TortoiseGit and just pull from master. Trying to pull from a branch other than master causes it to hang. I'll have to wait until somebody integrates it into master :( Thanks for verifying that's it's a bug and not my senility kicking in early...

-Frank
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by chrisb »

GeneFC wrote: Sat Sep 12, 2020 2:29 am
umill wrote: Sat Sep 12, 2020 1:46 am for the python files are all changes to the source loaded if we just restart Freecad?
...
I believe it is also possible to reload some Python files even without restarting FreeCAD, but I am not sure this is universal. I always restart.
When I work on post processor xyz_post I do the following in python console:

Code: Select all

import xyz_post
from importlib import reload
reload(xyz_post)
For reloading it again it is sufficient to repeat the last command. In Python console it is sufficient to type a unique prefix, e.g. "rel" and use the up-arrow to repeat a command.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
falviani
Posts: 250
Joined: Tue May 07, 2019 8:49 pm

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by falviani »

Hi,

I pulled from source tonight (I use the tortoiseGit shell extension) with a number of merges by Sliptonic into master, including what looks like a fix for the path generation. Unfortunately, it doesn't change the bad code generation - all cuts, which are supposed to end up at z = -12.7, immediately plunge to -13.2. Perhaps looking at the project /gcode files I attached a couple of posts back, might give some further insight into the problem.

Thanks for your insights,
Frank
umill
Posts: 12
Joined: Tue Feb 11, 2020 4:32 pm

Re: Pocket path generated only on face depth if object is reversed or origin moved

Post by umill »

Hi Frank,

I tried with the latest source and the problem seems to have been resolved :)
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22478 (Git)
Build type: Release
Branch: master
Hash: 38ba4c11c1dea1486acbb756fa336b6cb1d5b7ec
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)

I checked your file and the problem may have been that you set the finish depth to 12mm.
Finish depth is defined as the depth of the final cut, so that may have been the reason the path jumped to the final depth.
Please see attached with the final depth set to 0mm.
Attachments
SprayPaintRack.FCStd
(191.92 KiB) Downloaded 20 times
Post Reply