Getting started with Path in v0.17

Here's the place for discussion related to CAM/CNC and the development of the Path module.
sliptonic
Posts: 597
Joined: Tue Oct 25, 2011 10:46 pm

Re: Getting started with Path in v0.17

Postby sliptonic » Sun Dec 11, 2016 3:28 pm

jcf wrote:To find the bugs I would like to dive deeper into the Path.py code.
Is there a place where I could find helpful documentation?


Yes! Our evil master plan to leave enough bugs to annoy people into helping is working! :twisted:

Yorik's wiki has some helpful information.

All the Path python code is under /Mod/Path and most of it is under /Mod/Path/PathScripts. The names are pretty self descriptive. The pre and post processors have a specific naming scheme. The .ui files are compiled into a resource but the sources are in /src/Mod/Path/Gui/Resources/panels

I stay logged in to IRC on the #freecad channel if you want to chat. I'll do whatever I can to help you get going.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Getting started with Path in v0.17

Postby jcf » Sun Dec 11, 2016 6:07 pm

Yes! Our evil master plan to leave enough bugs to annoy people into helping is working! :twisted:

Yeah, it is! :lol:
I would be very glad if I could help. Let's hope that I will be able to spend enough time on it (and not get too frustrated :-) )

Yorik's wiki has some helpful information.

I think I stumbled already over this. Yes it was helpful.

I stay logged in to IRC on the #freecad channel if you want to chat.

I'm sorry, but I am not used to this "#" stuff. I prefer mail or something like this forum.

I'll do whatever I can to help you get going.

That's very nice!

Could we start with this:

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

Gui.activateWorkbench("PathWorkbench")

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

# set feed rates
FreeCAD.ActiveDocument.getObject("TC").HorizFeed = '200 mm/s'
FreeCAD.ActiveDocument.getObject("TC").VertFeed = '200 mm/s'
[color=#BF0040]FreeCAD..ActiveDocument.getObject("TC").HorizRapid = '500 mm/s'[/color]
FreeCAD..ActiveDocument.getObject("TC").VertRapid = '500 mm/s'
FreeCAD..ActiveDocument.getObject("TC").SpindleSpeed = 10000.00


I get this error:
    <unknown exception traceback><type 'exceptions.SyntaxError'>: ('invalid syntax', ('/media/jcf/sda2_DOC/8_LINUXandOpenSource/CAD/FreeCAD_macros/path_macros/1_path_init.fcmacro', 32, 9, 'FreeCAD..ActiveDocument.getObject("TC").HorizRapid = \'500\'\n'))

which I find quite strange.

Can you tell me anything about it?
sliptonic
Posts: 597
Joined: Tue Oct 25, 2011 10:46 pm

Re: Getting started with Path in v0.17

Postby sliptonic » Sun Dec 11, 2016 7:36 pm

jcf wrote:Could we start with this:

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

Gui.activateWorkbench("PathWorkbench")

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

# set feed rates
FreeCAD.ActiveDocument.getObject("TC").HorizFeed = '200 mm/s'
FreeCAD.ActiveDocument.getObject("TC").VertFeed = '200 mm/s'
[color=#BF0040]FreeCAD..ActiveDocument.getObject("TC").HorizRapid = '500 mm/s'[/color]
FreeCAD..ActiveDocument.getObject("TC").VertRapid = '500 mm/s'
FreeCAD..ActiveDocument.getObject("TC").SpindleSpeed = 10000.00


I get this error:
    <unknown exception traceback><type 'exceptions.SyntaxError'>: ('invalid syntax', ('/media/jcf/sda2_DOC/8_LINUXandOpenSource/CAD/FreeCAD_macros/path_macros/1_path_init.fcmacro', 32, 9, 'FreeCAD..ActiveDocument.getObject("TC").HorizRapid = \'500\'\n'))

which I find quite strange.

Can you tell me anything about it?


I can't say much about the actual error. I can give some background though.
The early expectation was that rapid moves never have a speed associated with them. The machine always moves at its configured rapid rate so a command like 'G0 X10 Y10 F30' would be an error or the F parameter would just be ignored.

However, it turns out that's not universally true. There are machine controllers with a configurable rapid rate. Shopbot is one, there may be others.
So we need to allow the user to configure a horizontal and vertical rapid rate.

It should be up to the post processor to use the captured data appropriately. I started to implement this and ran in to a snag. I thought everything except the panel stuff had been commented out until I could get back to it.
sliptonic
Posts: 597
Joined: Tue Oct 25, 2011 10:46 pm

Re: Getting started with Path in v0.17

Postby sliptonic » Sun Dec 11, 2016 7:42 pm

As for your actual macro, you've got a couple typos in it.
This works better

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

Gui.activateWorkbench("PathWorkbench")

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

# set feed rates
FreeCAD.ActiveDocument.getObject("TC").HorizFeed = '200 mm/s'
FreeCAD.ActiveDocument.getObject("TC").VertFeed = '200 mm/s'
FreeCAD.ActiveDocument.getObject("TC").HorizRapid = '500 mm/s'
FreeCAD.ActiveDocument.getObject("TC").VertRapid = '500 mm/s'
FreeCAD.ActiveDocument.getObject("TC").SpindleSpeed = 10000.00
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Getting started with Path in v0.17

Postby jcf » Mon Dec 12, 2016 1:48 pm

you've got a couple typos in it.

Oops!
Sorry. I didn't see the double ".", and the color marking didn't work in code mode, I didn't realize that.

So now it works.

There seems to be no difference if I do this:

Code: Select all

FreeCAD.ActiveDocument.getObject("TC").HorizFeed = '200'

or if I add the 'mm/s':

Code: Select all

FreeCAD.ActiveDocument.getObject("TC").HorizFeed = '200 mm/s'


Why is the spindle speed a float and the feed a string?
I would suggest to omit the unit, see problem mentioned earlier (LinuxCNC interpretes as mm/min, if there is no unit it should be OK for everyone?)

OK, now that this is working I can try other things.
jcf
Posts: 35
Joined: Tue Nov 15, 2016 10:34 am

Re: Getting started with Path in v0.17

Postby jcf » Mon Dec 12, 2016 3:28 pm

This is my macro nb. 2 for generating the contour path:

Code: Select all

# -*- coding: utf-8 -*-
"""Does the contour path for the base object
Base object must be a face in V0.17!, not a wire"""
import FreeCAD
import PathScripts.PathContour as PathContour
import PathScripts.PathUtils as PathUtils

obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Contour")
PathContour.ObjectContour(obj)
PathContour._ViewProviderContour(obj.ViewObject)
obj.Active = True
obj.ClearanceHeight = 20.0
obj.StepDown = 1.0
obj.StartDepth= 0
obj.FinalDepth=-0.2            # this is interpreted as -2.0 in the GUI!
obj.SafeHeight = 12.0
obj.OffsetExtra = 0.0
obj.Direction = "CW"
obj.UseComp = True
obj.PlungeAngle = 90.0
PathUtils.addToJob(obj)
PathContour.ObjectContour.setDepths(obj.Proxy, obj)
obj.ViewObject.startEditing()


It works, however obj.FinalDepth is not correctly interpreted in the GUI, it is 10 times bigger than the value in the macro.
Where do I find the bug? In Python code or in the C code?

N.B.: I have used a very simple drawing for the test that consists of a rectangle for the outer bounding and a circle in the interior.
I had to upgrade the rectangle to be a face, otherwise making the contour didn't work.
sliptonic
Posts: 597
Joined: Tue Oct 25, 2011 10:46 pm

Re: Getting started with Path in v0.17

Postby sliptonic » Mon Dec 12, 2016 4:15 pm

jcf wrote:It works, however obj.FinalDepth is not correctly interpreted in the GUI, it is 10 times bigger than the value in the macro.
Where do I find the bug? In Python code or in the C code?

N.B.: I have used a very simple drawing for the test that consists of a rectangle for the outer bounding and a circle in the interior.
I had to upgrade the rectangle to be a face, otherwise making the contour didn't work.


I have a pull request (376) pending now that made some changes and improvements to how depths are handled. With that, I don't see your 10x problem. (I'm not saying that fixes it since the problem might be elsewhere, but please test with that and let me know)

The more sophisticated operations like Contour and Facing assume a solid model for the Base object. It makes more sense to work from 3D objects so we can derive depths appropriately. It's still possible to work on 2D geometry but you need to use operations like 'profile from edge'
chrisb
Posts: 1668
Joined: Tue Mar 17, 2015 9:14 am

Re: Getting started with Path in v0.17

Postby chrisb » Mon Dec 12, 2016 4:55 pm

jcf wrote:This is my macro nb. 2 for generating the contour path:
It works, however obj.FinalDepth is not correctly interpreted in the GUI, it is 10 times bigger than the value in the macro.
Where do I find the bug? In Python code or in the C code?

N.B.: I have used a very simple drawing for the test that consists of a rectangle for the outer bounding and a circle in the interior.
I had to upgrade the rectangle to be a face, otherwise making the contour didn't work.


It might be the same problem we had here when we discussed dogbones: viewtopic.php?f=15&t=17768&start=30 and it seems to occur in FEM and Techdraw Worbench as well: viewtopic.php?f=10&t=18833.
GeneFC
Posts: 67
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Getting started with Path in v0.17

Postby GeneFC » Mon Dec 12, 2016 5:15 pm

jcf wrote:
I would suggest to omit the unit, see problem mentioned earlier (LinuxCNC interpretes as mm/min, if there is no unit it should be OK for everyone?)



I think omitting the units would be a mistake. There are still some of us working in customary US units (inch). I don't have a problem with working with mm, but I want to make sure I understand the units being used. FreeCAD is somewhat inconsistent in handling units, because each workbench can treat units differently.

Even LinuxCNC is not consistent. The user interface is based on length/minute, but the internals, including the "ini" file, are based on length/second.

Keeping the units in place will help reduce future confusion.

Gene
chrisb
Posts: 1668
Joined: Tue Mar 17, 2015 9:14 am

Re: Getting started with Path in v0.17

Postby chrisb » Mon Dec 12, 2016 5:54 pm

Internally FreeCAD uses mm only (that's what I have read in the forum) and in the preferences there is a possibility to select the units used in the GUI. Is there any use in mixing units? I think not.
The post processors I know are aware of a switch UNITS which can obtain the values 'G21' for using mm and 'G20' for inches. If set to inches the internally used values are converted.
I think we should keep this approach of using internally mm only and then without units (if FreeCAD does so in other places). At the frontend and backend they are converted if necessary. Thats a clear strategy which leads to problems only if in some places the conversion is not performed yet. If there are errors I am willing to find them and - if I can - remove them. Perhaps this mysterous x10 error is due to an error in that area.