PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

A place to share learning material: written tutorials, videos, etc.
CoderMusashi
Posts: 39
Joined: Mon Nov 19, 2018 8:26 pm

PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by CoderMusashi » Wed Dec 18, 2019 8:39 am

Here you will find the Step file and the finished FreeCad file for this video tutorial https://youtu.be/qqPFeRhajpM along with the code I used to do all the magic you see in the video. I start with a step file then turn it into a 2D to create some sketches from. Those sketches are used for creating the FeatureAreas. I then use some editing and macros to generate a step down tool path add the paths to a Job and simulate the result. The inspiration for this video came from realthunder and the post on https://forum.freecadweb.org/viewtopic.php?f=15&t=24833

Here is how I created the FeatureAreas into tool paths. It is similar to using the fromShape located in the supplimental commands menu under Path.

Code: Select all

import Path

# Change FeatureArea003 to the name of your FeatureArea,  Sketch, Shape, or Wire
p = App.ActiveDocument.FeatureArea003 

o = FreeCAD.ActiveDocument.addObject("Path::Feature","myPath")

#setting up our start vector from a choosen vertex
ov = p.Shape.Vertexes[0] #minus 1 from whatever the lower left Preselect info says
pos = ov.Point

o.Path = Path.fromShapes(p.Shape,start=pos,preamble = "false")
Here is the how I take GCode from a path created using the above code and save it to a file

Code: Select all

#change for your needs
file = "/home/yourusername/.FreeCAD/Macro/FeatureAreaTut/Path.nc"

gcode =App.ActiveDocument.myPath.Path.toGCode()

with open(file, 'w+') as f:
    f.write(gcode)
    f.close()
After editing the GCode saved to a file using the above Code I then cut and past the edited GCode from my text editor into this next macro. I then run the macro and it creates a new Path based on what I have edited

Code: Select all

#cut and paste gcode and create a Path::Feature object
import Path
lines = """
paste your Edited GCode here
"""
p = Path.Path()
p.setFromGCode(lines)
o = App.ActiveDocument.addObject("Path::Feature", "myPath") #rename mypath as you see fit
o.Path = p
This Last bit of code is what I use to take the edited tool path that I like and make it step down and repeat until it gets to a specified Z Depth.

Code: Select all

from PySide import QtCore, QtGui
#create a simple input dialog box to get zdepth
zd, okPressed = QtGui.QInputDialog.getText(None, 'Z Cut Depth', '9.525')

#create a simple input dialog box to get cuts per pass or step down amount
stepdown, okPressed = QtGui.QInputDialog.getText(None, 'Cut Depth per pass', 'Step down amount .635')

#create a new Path obj
o = FreeCAD.ActiveDocument.addObject("Path::Feature","myPath")
#variable setup for z step down for loop
zdepth = float(zd)
stpdwn = float(stepdown)
numofpass, lastpass = divmod(zdepth,stpdwn)
numofpass = int(numofpass)

#set p3 to the Path already created with wiretopath macro the first macro in this forum post
p3 = App.ActiveDocument.myPath003.Path #change mypath1 to your paths name

#loop for step down process
for i in range(numofpass):  
        curzdepth = (1+i) * stpdwn
        #move to our x,y start point
        p = Path.Command(" X232.318841 Y6.350000") #change this to your starting  x and y location
        # add the first path command to our new path object
        o.Path .addCommands( p)
       #p is our z current cut depth
        p = Path.Command("G0 Z-{0:.3f} \n".format(curzdepth))
        #add p to our path object
        o.Path.addCommands(p)
        #add our tool path p3 which is the path pattern we want repeated to our new path object
        o.Path.addCommands(p3.Commands)

#last at total zdepth
#move to x,y start point
p = Path.Command(" X232.318841 Y6.350000") #change this to your starting  x and y location
o.Path .addCommands( p)
p = Path.Command("G0 Z-{0:.3f} \n".format(zdepth))
o.Path.addCommands(p)
o.Path.addCommands(p3.Commands)

#add it to the job
# PathScripts.PathUtils.addToJob(App.ActiveDocument.myPath)
# add a tool controller property to the path
# App.ActiveDocument.myPath.addProperty("App::PropertyLink", "ToolController")
I save these as 4 separate macros

Files to follow along with video link from the top.
tut1.FCStd
(71.24 KiB) Downloaded 7 times
featurearea.step
(47.29 KiB) Downloaded 8 times
Last edited by CoderMusashi on Wed Feb 12, 2020 9:22 pm, edited 6 times in total.
User avatar
freman
Posts: 904
Joined: Tue Nov 27, 2018 10:30 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by freman » Wed Dec 18, 2019 9:47 am

thanks for doing this, I'm keen to see you video but ...
Private video
Sign in if you've been granted access to this video
Do you need to alter some settings?
CoderMusashi
Posts: 39
Joined: Mon Nov 19, 2018 8:26 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by CoderMusashi » Wed Dec 18, 2019 10:16 am

Had to enable the youtube account for longer video. It should be up shortly I'd imagine. I have not made a video in over a year. This one was a little longer. The work is so much faster when you don't have to talk and explain what is going on.
User avatar
freman
Posts: 904
Joined: Tue Nov 27, 2018 10:30 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by freman » Wed Dec 18, 2019 10:55 am

yes, I find videos are rather inefficient means of communicating how to do something. Most folks seem more interested in making 15min vid just to make "content" for their channel or for the pleasure of seeing themselves talk. Usually the screen resolution is not good enough to be able to make out what on the screen shots either.

Sliptonic has managed to produce some quite concise vids, but it's still rather labourious be "talked though" how to do something.

I generally find a few screenshots and explicative text a more efficient means of communication.

I'll wait until you upload has finished and give it a look . How long does it last ?
User avatar
freman
Posts: 904
Joined: Tue Nov 27, 2018 10:30 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by freman » Wed Dec 18, 2019 1:45 pm

If someone who understands these tools , it may be good to have some documentation on the wiki instead of blank pages.

https://www.freecadweb.org/wiki/Path_Area
https://www.freecadweb.org/wiki/Path_Area_Workplane

Even those pages seem to have wrong name for the tools: Area instead of FeatureArea.
vocx
Posts: 2811
Joined: Thu Oct 18, 2018 9:18 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by vocx » Wed Dec 18, 2019 6:04 pm

freman wrote:
Wed Dec 18, 2019 10:55 am
...
I generally find a few screenshots and explicative text a more efficient means of communication.
...
Aren't people interesting? I remember another post in the help section mentioning that they wanted complete tutorials with voiceovers instructing them what they were doing, because just a few pictures with text was not enough.

Truth is, it's impossible to please everybody. Some people like things one way, and other people want the opposite of that. That's life.
To support the documentation effort, and code development, your donation is appreciated: paypal.
vocx
Posts: 2811
Joined: Thu Oct 18, 2018 9:18 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by vocx » Wed Dec 18, 2019 6:06 pm

freman wrote:
Wed Dec 18, 2019 1:45 pm
If someone who understands these tools , it may be good to have some documentation on the wiki instead of blank pages.
...
Do bother the Path guys about this. I honestly don't understand why they don't write documentation. They code a lot, they merge many branches into the master repository (check the GitHub), but they rarely write about it. It's only a few videos, some forum posts, and that's it. Coherent documentation is lacking.
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
freman
Posts: 904
Joined: Tue Nov 27, 2018 10:30 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by freman » Wed Dec 18, 2019 8:38 pm

I honestly don't understand why they don't write documentation.
Agreed, RealThunder has contributed huge amounts of code , just the featureArea stuff was about 5000 lines, IIRC, then there's significant work on the morphology problem and the whole assembly3 project, but with nothing more than a hover hint to go from I don't know how he hopes anyone will ever use it. I'm not going to start reading the source code to find out what it does.

At least in the CoderMusashi efforts with nearly an hour of video, no one will accuse him of not explaining it, but suspect I could get the same level of understanding from 5 minutes of reading.

Anyway, he's got me interested in featureArea and given a glimpse of how to use it. That's ahead of where I was yesterday, so many thanks for that effort.

It seems this may at least provide some workarounds for the limitations in current tools even that it requires quite a lot of detailed configuration to get a machine path. That's better than some situations which don't seem to have a better solution.

Tool paths which refuse to cut air is a constant annoyance, which we've only just found a partial solution to with a mod to boundary setting code and a boundaryDressUp.
chrisb
Posts: 21375
Joined: Tue Mar 17, 2015 9:14 am

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by chrisb » Thu Dec 19, 2019 12:22 am

Thanks for the tutorial.
If I understand it right, the FeatureArea provides what had been asked several times before: how to create a path for a certain edge, here defined as the edge of a sketch.
Can you confirm the following - or correct if necessary:
- FeatureArea is based on sketches or wires
- it works basically without a job. If a job should be used it needs some scripting
- the user is responsible for heights and depths
- he is responsible for radius compensation, e.g. by using the machine's G41/G42 commands
- to create a path it needs a script
- the paths are not post processed (not sure about this after job creation)
--------------

Some comments on the sketching, in case somebody not familiar with sketching wants to follow:

- You can use Box selection in Sketcher if you want to select more than one element. Note: selecting from right to left selects all elements touched, while selecting from left to right encloses all elements completely inside of the box.

- You can use references to external geometry, which speeds up creating the sketches.
User avatar
freman
Posts: 904
Joined: Tue Nov 27, 2018 10:30 pm

Re: PathWorkbench FeatureArea tool and Reversing a Step file to create tool paths

Post by freman » Thu Dec 19, 2019 7:41 am

This is a quote from Realthunder where he originally presented this in 2017.

[quote"Realthunder"]Here, I just show you with the minimum code necessary. There are tons of settings you can play with for fine tuning. Make no mistake, Path.Area is for developers. Nothing is hardcoded. Every option is exposed as a parameter.
[/quote]
https://forum.freecadweb.org/viewtopic.php?f=15&t=20273

Unless that has fundamentally changed since merging ( and I don't find any evidence of that ) I guess this does require cut/paste coding to achieve useful paths.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests