Modify Path to my needs. How?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Fri Jan 20, 2017 12:20 pm

sliptonic wrote:This sounds a lot like another kind of application called a 'conversational cnc' program

Yes, maybe it is close to that.
In Linuxcnc (that I use) I know the possibility to enter Gcode directly. Is that what you mean?
sliptonic
Posts: 621
Joined: Tue Oct 25, 2011 10:46 pm

Re: Modify Path to my needs. How?

Postby sliptonic » Fri Jan 20, 2017 3:22 pm

No. Features is an add-on gui for building gcode programs. I think it was started by the same Russian programmer who wrote the gcode exporter plug-in for Inkscape. I've not used it myself but it has gotten a lot of attention in the Linuxcnc world.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Tue Feb 07, 2017 12:51 pm

I have found this wiki about path:
https://github.com/yorikvanhavre/FreeCA ... ath-module

Is there a place where I could find some more information?
sliptonic
Posts: 621
Joined: Tue Oct 25, 2011 10:46 pm

Re: Modify Path to my needs. How?

Postby sliptonic » Tue Feb 07, 2017 1:49 pm

jcf wrote:I have found this wiki about path:
https://github.com/yorikvanhavre/FreeCA ... ath-module

Is there a place where I could find some more information?


You'll have to be more specific about what you're looking for.
Actual written documentation is still lacking so you might be studying source code.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Tue Feb 07, 2017 3:55 pm

sliptonic wrote:
You'll have to be more specific about what you're looking for.


For a start, I have one specific question:
When I press the "Create Contour Path" button, where do I go in PathScripts?
Where is the entry point?

To create a path job, I have done this:

Code: Select all

obj = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Job")
PathJob.ObjectPathJob(obj)
PathLoadTool.CommandPathLoadTool.Create(obj.Name)
tl = obj.Group[0]
tool = Path.Tool()
tool.Diameter = 3.0
tool.Name = str(tool.Diameter)+"mm mill"
tool.CuttingEdgeHeight = 15.0
tool.ToolType = "EndMill"
tool.Material = "HighSpeedSteel"
obj.Tooltable.addTools(tool)
tl.ToolNumber = 1

# GUI edit tool
obj.ViewObject.Proxy.deleteOnReject = True
obj.ViewObject.startEditing()
# close GUI window


What puzzles me is the editing.
I would like to know what's going on there.

Thanks for your patience, sliptonic!
sliptonic
Posts: 621
Joined: Tue Oct 25, 2011 10:46 pm

Re: Modify Path to my needs. How?

Postby sliptonic » Tue Feb 07, 2017 4:25 pm

jcf wrote:
sliptonic wrote:
For a start, I have one specific question:
When I press the "Create Contour Path" button, where do I go in PathScripts?
Where is the entry point?

Take a look in the PathScripts/PathContour.py file.

You'll see classes for the TaskPanel, the contour object itself, the viewprovider, etc. There's a class called CommandPathMillFace. This is the command that gets registered if the GUI is up. The Activated method is the code executed when the button is pushed.

...
# GUI edit tool
obj.ViewObject.Proxy.deleteOnReject = True
obj.ViewObject.startEditing()
# close GUI window
[/code]

What puzzles me is the editing.
I would like to know what's going on there.


It fires a signal. It's executing the code in the ViewProviderFace.setEdit() method to close any other dialogs and open the task panel.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Wed Feb 08, 2017 7:28 am

Thank you, sliptonic.
That seems to be the information I needed! :D
I'll have a look at it as soon as I can.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Fri Feb 17, 2017 9:31 am

I have progressed a little bit in understanding the Path scripts.

Now I am able to create a path Job object and set my parameters:

Code: Select all

# -*- coding: utf-8 -*-
# Macro for initializing Path Job and setting tool and feed rate

import FreeCAD
import PathScripts.PathJob as PathJob
import PathScripts.PathLoadTool as PathLoadTool
import Path


# create Path Job
myjob = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Job")
PathJob.ObjectPathJob(myjob)

# get first drawing object and set it as job.Base:
objs = FreeCAD.ActiveDocument.Objects
firstobj = objs[0]
myjob.Base=firstobj

# Create tool
tool = Path.Tool()
tool.Diameter = 3.0
tool.Name = str(tool.Diameter)+"mm mill"
tool.CuttingEdgeHeight = 15.0
tool.ToolType = "EndMill"
tool.Material = "HighSpeedSteel"

# Load tool:
PathLoadTool.CommandPathLoadTool.Create(myjob.Name)
myjob.Tooltable.addTools(tool)
tl = myjob.Group[0]
tl.ToolNumber = 1

# set feed rates
tl.HorizFeed=200
tl.VertFeed = 200
tl.HorizRapid = 300
tl.VertRapid = 500

tl.SpindleSpeed = 10000.00

myjob.X_Max= 400
myjob.Y_Max= 300
myjob.Z_Max= 50
myjob.Z_Min= -80

myjob.UsePlacements = True


# eventually activate GUI edit tool
## myjob.ViewObject.Proxy.deleteOnReject = True
## myjob.ViewObject.startEditing()
# close GUI window



# activate Path workbench:
# Gui.activateWorkbench("PathWorkbench")


The Base object is the first object in the drawing, which in my test example is a Rectangle.

Then I create a contour:

Code: Select all

import PathScripts.PathContour

Gui.activateWorkbench("MyPathWorkbench")

# create contour object:
mycontour = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Contour")
PathScripts.PathContour.ObjectContour(mycontour)
PathScripts.PathContour._ViewProviderContour(mycontour.ViewObject)

# set properties:
mycontour.Active = True
mycontour.ClearanceHeight = 20.0
mycontour.StepDown = 1.0
mycontour.StartDepth= 0.0
mycontour.FinalDepth= -3.0
mycontour.SafeHeight = 12.0
mycontour.OffsetExtra = 0.0
mycontour.Direction = "CW"
mycontour.UseComp = True

PathScripts.PathUtils.addToJob(mycontour)
PathScripts.PathContour.ObjectContour.setDepths(mycontour.Proxy, mycontour)


and there seems to be something missing or wrong, but I don't know what.

I get these warnings:

Code: Select all

DeprecationWarning: For future usage 'Curve' will return 'Line' which is infinite instead of the limited 'LineSegment'.
If you need a line segment then use this:
Part.LineSegment(edge.Curve,edge.FirstParameter,edge.LastParameter)
To suppress the warning set BaseApp/Preferences/Mod/Part/General/LineOld to false
...


which seem to be due to my Rectangle Base object (creatzed with Face = True)

and at the end:

Code: Select all

Something unexpected happened. Unable to generate a contour path. Check project and tool config.


I suppose that
    either I have done something wrong / omitted something
    or my drawing Base object is not the right type for Curve / Libarea

Can anyone give me a hint?
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Fri Feb 17, 2017 5:30 pm

Actually my code seems to work! :D
I didn't notice because I forgot

Code: Select all

FreeCAD.ActiveDocument.recompute()

at the end.

Another thing is that I updated Freecad - daily ton 0.17R10101

The Path module I use is an older one however, can't tell from when.
(I wanted to keep this as it had made me nice G code once, and as sometimes when updating, the scripts in the /Mod folder had disappeared. So I am happy to have this one)
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Modify Path to my needs. How?

Postby jcf » Thu Feb 23, 2017 9:04 am

Now I can generate a contour path by script.

The next step is to attack the profile path.
I have looked at the code which seems to be more complex, while part of this complexity lies in guessing the base object as it seems to me.
I have not fully understood which kind of object this must be. May it be 2D? For my approach the easiest would be Rectangle, Circle etc.

Or would it be better to switch to 3D? Note that my decision to start with 2D and to write my own code was that there were difficulties making a path at all, and problems with changes in FreeCAD that made me going mad as what worked yesterday did not work today. So I hoped that if I understand the code I can build something that works for me, as long as FreeCAd is still evolving.

So my question is: how can I make a contour path by code, based on objects that I selected befor or that I set by code?