pythonical adding all the holes to an operation

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!
Erich Schulz
Posts: 141
Joined: Tue May 07, 2019 10:50 pm
Location: Brisbane, Australia

pythonical adding all the holes to an operation

Post by Erich Schulz »

so... I seem to like to climb before I can crawl

I would like to know how I automagically find all the holes in my board (potentially hundreds) and add them to helix operation

I'm thinking I need a little macro for this???

I have gotten as far as figuring out that the property of the operation I need to extend is operations 'Base' property

or is there an easier way on the UI that has escaped me??

Background:

:-)

I am making a little "pin board" project where I use a spreadsheet to enter the dimensions of a board, and some pin holes, and a count of holes in x & y

with some help (thanks again) I have been able to make said pin board model, and have moved onto the milling operation

(it has been suggested I use the "path array" operation for the milling. Even tho this maybe a good idea, let us put that to side for the moment)
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: pythonical adding all the holes to an operation

Post by RatonLaveur »

hi friend,

File, version :) and I'm happy to give it a look.

Cheers! :)
Erich Schulz
Posts: 141
Joined: Tue May 07, 2019 10:50 pm
Location: Brisbane, Australia

Re: pythonical adding all the holes to an operation

Post by Erich Schulz »

hi here is a tidied up version...

the goal is to be able to edit the spreadsheet and then produce g-code based on the updated data

i am interested in the the journey (ie how) rather than the destination (the finished product)
Attachments
pintable20.FCStd
(140.58 KiB) Downloaded 69 times
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: pythonical adding all the holes to an operation

Post by mlampert »

I might not be fully understanding what you want to do - but I think the Helix op already does that.

If you create a helix op, it's proxy is a subclass of PathCircularHoleBase.ObjectOp which has 2 functions to find and use all holes in a given object. Assuming your op is called PathHelix, the following snipped should find all holes and assign them to the op:

Code: Select all

App.ActiveDocument.PathHelix.Proxy.findAllHoles(App.ActiveDocument.PathHelix)
If you look at that function in PathCircularHoleBase.py it should give you some ideas.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: pythonical adding all the holes to an operation

Post by mlampert »

mlampert wrote: Tue Jul 09, 2019 3:07 pm

Code: Select all

App.ActiveDocument.PathHelix.Proxy.findAllHoles(App.ActiveDocument.PathHelix)
BTW - this has the same effect as pressing "Reset" in the UI.
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: pythonical adding all the holes to an operation

Post by RatonLaveur »

Playing with Profile Based and Faces and selecting "holes" i indeed realised that if path in this case can locate the circles and produce a combination of rapids and profiles on all holes by selecting just one face, then it surely would be able to extrapolate this to a Drilling Op.

Based on what your write mlampert it even seems like a simple solution.

Am i wrong?
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: pythonical adding all the holes to an operation

Post by mlampert »

Both, Drilling and Helix are based on PathCircularHoleBase - so both have support for finding all holes in the API and the UI.
User avatar
bill
Posts: 376
Joined: Fri Jan 09, 2015 9:25 pm

Re: pythonical adding all the holes to an operation

Post by bill »

mlampert wrote: Tue Jul 09, 2019 3:12 pm "Reset" in the UI.
mlampert wrote: Tue Jul 09, 2019 3:12 pm mlampert wrote: ↑
Tue Jul 09, 2019 11:07 am

Code: Select all

App.ActiveDocument.PathHelix.Proxy.findAllHoles(App.ActiveDocument.PathHelix)
If it is an "Automatic Selection" the call it that! i.e., AutoSelect

RESET is a misnomer that infers starting over and possibly trashing info/selection(s)/data.

Yeah, findAllHoles() sure sounds like an automatic selection to me.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: pythonical adding all the holes to an operation

Post by mlampert »

bill wrote: Tue Jul 09, 2019 6:59 pm RESET is a misnomer that infers starting over and possibly trashing info/selection(s)/data.
which is exactly what it does
User avatar
bill
Posts: 376
Joined: Fri Jan 09, 2015 9:25 pm

Re: pythonical adding all the holes to an operation

Post by bill »

Then call it SELECT ALL - more equivalent to findAll(); anything but Reset.

It is not obvious or intuitive

Question: Path-Hoppa: When one opens up the drilling OP (and i just did), and the UI is blank, why on earth would you click on resetting-nothing?

Except for that is just one of the ways it works.

I have used this RESET button hundreds of times, and laughed to myself just as many!
Post Reply