Helix machining for circular holes

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!
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Helix machining for circular holes

Post by m0n5t3r »

Right now, it doesn't work with freecad-daily :

Traceback (most recent call last):
File "/usr/lib/freecad-daily/Mod/Path/PathScripts/PathHelix.py", line 472, in Activated
toolLoad = PathUtils.getLastToolLoad(obj)

'module' object has no attribute 'getLastToolLoad'

Can I get some comments on https://github.com/m0n5t3r/FreeCAD/comm ... 7f7bb67f01? it mostly fixes the problem (I just lifted and adapted the code from the recent dogbone dressup fix, I don't know much about freecad internals); the only issue I have with it is the fact that the tool controller property doesn't seem to be saved or passed around correctly, which leads to annoying prompts if there are several tools defined.

And 2 nitpicks: is it possible to 1) make it sort the holes in a way that makes sense [1], and 2) not lift the tool after every spiral?

[1]
Screenshot from 2017-03-30 03-26-11.png
Screenshot from 2017-03-30 03-26-11.png (25.26 KiB) Viewed 2225 times
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Helix machining for circular holes

Post by sliptonic »

m0n5t3r wrote:Right now, it doesn't work with freecad-daily :

Traceback (most recent call last):
File "/usr/lib/freecad-daily/Mod/Path/PathScripts/PathHelix.py", line 472, in Activated
toolLoad = PathUtils.getLastToolLoad(obj)

'module' object has no attribute 'getLastToolLoad'

Can I get some comments on https://github.com/m0n5t3r/FreeCAD/comm ... 7f7bb67f01? it mostly fixes the problem (I just lifted and adapted the code from the recent dogbone dressup fix, I don't know much about freecad internals); the only issue I have with it is the fact that the tool controller property doesn't seem to be saved or passed around correctly, which leads to annoying prompts if there are several tools defined.

And 2 nitpicks: is it possible to 1) make it sort the holes in a way that makes sense [1], and 2) not lift the tool after every spiral?

[1] Screenshot from 2017-03-30 03-26-11.png
I'll try to take a look but I'm traveling right now so it might be a bit. There should only be prompts if there are multiple tool controllers in the job and you don't have one selected in the tree when you create the operation. Those prompts would be appropriate since the operation has no way of knowing which tool controller to use.

My longer term goal is to combine helical hole and Path Drilling into a single 'circular hole tool' This would have a better UI for sorting holes, filtering by size, enabling and disabling groups of holes, etc. The user would then choose which method to apply to all the selected holes; helical, drilling, or some other method. Unfortunately, I just haven't had time to finish it.

Part of that effort was to implement a very basic Traveling Salesman Problem solver for more efficient routing. If someone wants to pick up the ball and run with it, I'll push what I have now to a branch on my repo and help where I can. It shouldn't be too hard to finish.
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Helix machining for circular holes

Post by m0n5t3r »

sliptonic wrote: Those prompts would be appropriate since the operation has no way of knowing which tool controller to use.
I got that, but I think I'm adding the tool controller to the wrong object somewhere, because the selection dialog pops up every time I want to edit the PathHelix (and if adding with multiple holes already selected it would ask once for each hole AFAIR, but I added a check to see if it's already set and now it just asks once and ignores whatever you select after the first time for reasons I don't understand / haven't had time to dig into).
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Helix machining for circular holes

Post by m0n5t3r »

[edit: pull request URLs]
I created a pull request for the tool controller fix, and I took a stab at job sorting this morning.

I would say this is an improvement over the image I posted previously:
Screenshot from 2017-04-29 11-03-49.png
Screenshot from 2017-04-29 11-03-49.png (8.81 KiB) Viewed 2100 times
Screenshot from 2017-04-29 11-46-35.png
Screenshot from 2017-04-29 11-46-35.png (12.74 KiB) Viewed 2100 times
I think this method (nearest neighbor weighted by the distance to one axis) is good enough for machining purposes; I'm no computer scientist, though, my theoretical knowledge of algorithms has quite a lot of holes in it :) (pun not intended)
User avatar
bill
Posts: 376
Joined: Fri Jan 09, 2015 9:25 pm

Re: Helix machining for circular holes

Post by bill »

m0n5t3r wrote: I think this method (nearest neighbor weighted by the distance to one axis) is good enough for machining purposes; I'm no computer scientist, though, my theoretical knowledge of algorithms has quite a lot of holes in it :) (pun not intended)
Ha, Ha, Ha, ... so funny!

"Order is everything!"
Big step in the right direction/improvement; slip* will probably appreciate the help! And very timely at that; was just about to mill this part. This make it easier to plan for clamp-down of this part!
BBRing.png
BBRing.png (21.83 KiB) Viewed 2078 times
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Helix machining for circular holes

Post by chrisb »

I think it is good to have a well defined algorithm. Although it is easy to fool the next neighbour algorithm it is on the other side easy to support in case it ever gets necessary, e.g. by dividing the drilling job in two separate tasks. If the order is left e.g. to the somewhat arbitrary order that is provided by the OCC numbering of faces and edges nothing can be done.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Helix machining for circular holes

Post by chrisb »

bill wrote: was just about to mill this part. This make it easier to plan for clamp-down of this part!
Bill, some of the vertical moves seem to be rapid moves and some seem to be normal. Can you find a reason for that?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Helix machining for circular holes

Post by m0n5t3r »

chrisb wrote:I think it is good to have a well defined algorithm. Although it is easy to fool the next neighbour algorithm it is on the other side easy to support in case it ever gets necessary, e.g. by dividing the drilling job in two separate tasks. If the order is left e.g. to the somewhat arbitrary order that is provided by the OCC numbering of faces and edges nothing can be done.
It is not purely nearest neighbor, it's a bit modified by adding the X coordinate to the distance; this improves things dramatically because it adds ... gravity to the algorithm (nearest neighbor tends to wander and make funny paths if there are several neighbours at the same distance, like in the rectangular grid I tested initially).
roivai
Posts: 117
Joined: Thu Feb 02, 2017 5:29 pm
Location: Oulu, Finland

Re: Helix machining for circular holes

Post by roivai »

Thank you m0n53r for this fix, it seems that it got merged just a few moments ago. One thing I noticed when testing this is that if you play around with those Absolute start height and Absolute final height -settings and accidentally end to situation where the start height < finish height for example and the "job" that gets into your sorting algorithm is empty, the whole FreeCAD freezes, so I quess your sort_jobs function never returns or something. I got rid of that by simply:

Code: Select all

if len(drill_jobs) > 0:
    drill_jobs = self.sort_jobs(drill_jobs)
There is still something fishy about setting those absolute heights, but I think that has been the case for a long time and it has nothing to do with your fix.

Pekka
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Helix machining for circular holes

Post by sliptonic »

Cool! Nice feature m0n5t3r. It's great to go away for a few days, come back and find new features. I should leave more often. :D

Perhaps you'll consider abstracting your method out, moving it to PathUtils, and implementing it for Drilling as well.
Post Reply