Path Pocket Shape: 4th-axis Integration

Here's the place for discussion related to CAM/CNC and the development of the Path module.
User avatar
Russ4262
Posts: 222
Joined: Sat Jun 30, 2018 3:22 pm

Path Pocket Shape: 4th-axis Integration

Postby Russ4262 » Wed Apr 24, 2019 4:43 am

Greetings FreeCAD users.
I would like to dedicate this topic to the integration of 4th-axis into the Path Pocket Shape tool in the PathWB.

I have attached the two modified scripts; you need both. Place them in your FreeCAD/Mod/Path/PathScripts directory, AFTER renaming your originals for safe keeping. Rename the new scripts to the original script names. Restart FreeCAD and have fun. I do not know how far backwards compatibility will work. Use at your own risk.

There is an existing bug related to the Extension Corners feature. Selecting a face that requires rotation (4th-axis) will cause an error, removing an unacceptable face(s) from the new operation. Simply double click on the same operation, go to the Base Geometry tab in the task window for the operation, select the face, add it to the list, then click OK. This should give you the desired operation. You might have to repeat this process, or click the blue recompute icon.
I think, in order to correct the related error, we will also have to integrate the 4th-axis pre-rotation into the Extension Corners code sections.

There is a temporary property, "B_Axis Error Override," in the Path property section. Set to TRUE if you wish to align B-axis(Y-axis) rotations with the model for inspection purposes.
UPDATE: 2019-05-12 This will make these rotations look wrong in FC versions older than pre_0.19.16653 roughly, but will be correct in the real world. Versions released after PR #2114, roughly pre_0.19.16653, will render B-axis(Y-axis) rotations correctly with this property set to FALSE.
Regardless: Set "B_Axis Error Override" to FALSE before exporting gcode !

There is a "Reverse Direction" property in the Pocket property section. Should you need the pocket path orientation reversed (flipped 180 degrees), set this to TRUE. Hopefully this will yield the desired result.

Path Pocket Shape 4th-axis Usage:
To use the 4th-axis feature, do the following.
  1. Click on the Path Pocket Shape icon to start the operation.
  2. Click the OK to create the operation - no faces selected
  3. Select the new Pocket_Shape operation in task window
  4. In the operation's Properties list, scroll to Path section and change the "Enable Rotation" property to the desired 4th-axis setting.
  5. Re-compute the operation
  6. Double click on the same operation, to edit settings in the task window.
  7. Open the 'Base Geometry' tab. Select one face (preferred at the moment) and click the 'Add' button, placing that face in the Base Geometry list.
  8. Change the other operation settings as desired.
  9. Click OK to save and apply the changes.

I appreciate the help testing the code. Please post pics, source model files and FC info when posting feedback. This is looking better every time!

Thanks,
Russell

UPDATE: 2019-04-26 Version 1f_testing uploaded :: should respect XYZ linear Model translations in Job setup; added axis selection property
UPDATE: 2019-04-30 This topic is also related to PR #2114.
UPDATE: 2019-04-30 Updated scripts to Rev. 1h Testing. Same version as currently in the PR. Repaired broken Profile Faces and Mill Faces operations based upon PathAreaOp.py script. Also addressed depthparams issue detected by @Sliptonic via Mill Faces op.
UPDATE: 2019-05-06 Updated PathPocketShape.py script to Rev. 1i Testing. Thanks to @RatonLaveur for identifying broken multi-face selection in Geometry tab of operation settings. Now fixed. Issue remains with tool controller.
UPDATE: 2019-05-12 Updated both PathPocketShape.py and PathAreaOp.py scripts attached to versions just copied from FC master since being committed in PR #2114.
UPDATE: 2019-06-01 Updated both PathPocketShape.py and PathAreaOp.py scripts attached to version 1k-testing. Fix for random repositioning of job model. Now creates additional clone per axis_angle rotation for basis of rotational pockets, then destroys temp clone used. You will need to re-create Path_Shape operations because the "Use Rotation" property is renamed "Enable Rotation" to prepare for UI integration.
UPDATE: 2019-06-01 Updated both PathPocketShape.py and PathAreaOp.py scripts attached to version 1k-testing-patch. Cleaned up code a bit and adapted for more universal integration of 4th-axis into the PathWB.
UPDATE: 2019-06-11 Updated both PathPocketShape.py and PathAreaOp.py scripts attached to version 2f-testing. Simplified code related to 4th-axis. Fixed model repositioning issue. Same version as PR #2231.
UPDATE: 2019-06-13 Updated both PathPocketShape.py and PathAreaOp.py scripts attached to version 2g-testing. Made some fixes pointed out by the involved and active @RatonLaveur. Additional cleaning of code and other feature tweaks.


OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16886 (Git)
Build type: Release
Branch: master
Hash: ed47e962d2c821bf1792889f6d7bdf457dcf6c9e
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)
Attachments
PathPocketShape_2g-testing.py
PathPocketShape_2g-testing.py
(39.45 KiB) Downloaded 27 times
PathAreaOp_2g-testing.py
PathAreaOp_2g-testing.py
(42.97 KiB) Downloaded 28 times
PathPocket-4th-axis_1d-C.png
Reverse Direction property. Try if pocket path is oriented through model, rather than toward exterior.
PathPocket-4th-axis_1d-C.png (171.15 KiB) Viewed 909 times
PathPocket-4th-axis_1d-B.png
B-axis(Y) error override: FOR INSPECTION PURPOSES ONLY. Set to FALSE for exporting gcode.
PathPocket-4th-axis_1d-B.png (180 KiB) Viewed 909 times
PathPocket-4th-axis_1d-A.png
B-axis(Y) rotations render incorrectly, visually in FreeCAD. They are correct in gcode and real-world application.
PathPocket-4th-axis_1d-A.png (164.55 KiB) Viewed 909 times
Last edited by Russ4262 on Thu Jun 13, 2019 5:59 am, edited 16 times in total.
User avatar
Wsk8
Posts: 46
Joined: Fri Dec 07, 2018 6:24 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Wsk8 » Wed Apr 24, 2019 3:45 pm

Hello,

i tried it and completly failed :D
What am i doing wrong?

OS: Ubuntu 19.04
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1.
Build type: Release
Python version: 3.7.3
Qt version: 5.12.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
Attachments
4th_Test.FCStd
(46.56 KiB) Downloaded 20 times
Bildschirmfoto von 2019-04-24 17-34-16.png
Bildschirmfoto von 2019-04-24 17-34-16.png (197.12 KiB) Viewed 903 times
User avatar
Russ4262
Posts: 222
Joined: Sat Jun 30, 2018 3:22 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Russ4262 » Wed Apr 24, 2019 4:06 pm

Hello,
Wsk8 wrote:
Wed Apr 24, 2019 3:45 pm
i tried it and completly failed :D
What am i doing wrong?
I opened your file. I found a part of the problem in the job setup. The paths you see are based on the Body object, not the Model object. I don't know if this is related to the code modifications or was pre-existing. I recall a similar issue existing with the 3D Surface operation. I'm short on time, but I'll get back to you.

If you toggle visibility of the Body to on, and the Model in the Job to off, you will see two of the three operations align to the Body object. The top pocket needs "Reverse Direction" flag set to TRUE in the properties.

mfg
Russell
Last edited by Russ4262 on Wed Apr 24, 2019 7:14 pm, edited 1 time in total.
User avatar
Wsk8
Posts: 46
Joined: Fri Dec 07, 2018 6:24 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Wsk8 » Wed Apr 24, 2019 4:36 pm

Thx, now it looks much better! Didn't thought about this problem, since all ops are usually based on the model :)

The rest looks good, only the starting depths seems a bit high.

mfg
cox
Posts: 963
Joined: Wed Nov 26, 2014 11:37 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby cox » Wed Apr 24, 2019 6:45 pm

Russ4262 wrote:
Wed Apr 24, 2019 4:43 am
Greetings FreeCAD users.
Hi, I really enjoy reading your posts, to the point that I am starting to be concerned for my F5 key. :-) thanks a bunch for the work you are doing!. Looking forward to a time where I can revive my china 6040 4 axis and have a play with this. For the time being it feels like, all I have time to play with is diapers :-)
Need help? Feel free to ask, but please read the guidelines first
herbk
Posts: 1501
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Re: Path Pocket Shape: 4th-axis Integration

Postby herbk » Wed Apr 24, 2019 7:53 pm

Hi Russel,

great work!
I'm thinking about building a new (a bit bigger) CNC router since a while, - it seams it has to have 4 axis (at least). ;) ;)

Dos this working without OpenCamLib? because i still have probs to get it run...
Gruß Herbert
User avatar
Russ4262
Posts: 222
Joined: Sat Jun 30, 2018 3:22 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Russ4262 » Thu Apr 25, 2019 2:52 am

Evening,
I have investigated the problem of the paths not aligning to the Model. It is within the new, modified code. I have to apply the translational adjustments of the Model in the Job setup into the rotational translations for the pockets. This is a little challenging... ;)
Wsk8 wrote:
Wed Apr 24, 2019 4:36 pm
Thx, now it looks much better! Didn't thought about this problem, since all ops are usually based on the model :)
The rest looks good, only the starting depths seems a bit high.
Starting depths currently are calculated with about three variables, some of which include the rotational limits of the Model. I can adjust them.

Russell
User avatar
Wsk8
Posts: 46
Joined: Fri Dec 07, 2018 6:24 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Wsk8 » Thu Apr 25, 2019 6:55 am

And could you please add the option to select the used Axis like "A" or "A and B"? Not everyone has 5 Axis ;)

Mfg
User avatar
Russ4262
Posts: 222
Joined: Sat Jun 30, 2018 3:22 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Russ4262 » Fri Apr 26, 2019 1:15 pm

Good day,
I have addressed the issues you identified - at least my tests have positive results.
Wsk8 wrote:
Wed Apr 24, 2019 4:36 pm
... all ops are usually based on the model :)

The rest looks good, only the starting depths seems a bit high.
The pockets should now respect the XYZ translations available in the Job setup. I have not attempted to use the rotation adjustments in the Job setup. Also, I adjusted starting height calculations.

I have attached your same file, with results using these adjustments mentioned.

Wsk8 wrote:
Thu Apr 25, 2019 6:55 am
And could you please add the option to select the used Axis like "A" or "A and B"? Not everyone has 5 Axis ;)
Done. The default is "A & B".

Just remember you will have to use the "Reverse Direction" property in some cases due to face orientation.

I will update the scripts in the initial post for this topic when I get back home.

Thanks for the help.
Russell
Attachments
4th_Test_1f.png
Body in blue, Model in pink
4th_Test_1f.png (141.08 KiB) Viewed 744 times
Last edited by Russ4262 on Fri Apr 26, 2019 1:50 pm, edited 1 time in total.
User avatar
Russ4262
Posts: 222
Joined: Sat Jun 30, 2018 3:22 pm

Re: Path Pocket Shape: 4th-axis Integration

Postby Russ4262 » Fri Apr 26, 2019 1:17 pm

herbk wrote:
Wed Apr 24, 2019 7:53 pm
Hi Russel,

great work!
I'm thinking about building a new (a bit bigger) CNC router since a while, - it seams it has to have 4 axis (at least). ;) ;)

Dos this working without OpenCamLib? because i still have probs to get it run...
Thanks, Herbk.
I don't think that OCL is required; however, when I attempt to load the PathWB without OCL, I receive an error and the tools do not load. It appears there is a dependency error thrown for PathWB in general if OCL is unavailable. I'll try to run more tests and investigate further.

Russell