Start Points and order in face based toolpaths

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!
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Start Points and order in face based toolpaths

Post by sliptonic »

pauluzs wrote: Wed Mar 13, 2019 6:16 pm
About the
The weakness of the Heeks implementation was that it didn't handle profiles with multiple disconnected wires where the user needs to configure multiple start points.
can you give some more info on that? Do you mean rapid moves between entry points in a connected toolpath or is there a toolpath that will produce disconnected wires?
Taking as an example your image below with an outside contour and five inside contours. Each of the inside contours is a wire with one or more edges and the CNC must rapid between them. If the user picks five points to identify start points, you must keep track of which point corresponds to which wire. This is where I remember HeeksCNC being weak. For simple cases, it's, well, simple. But it can get more complicated.

How did it handle the start and stop points? as one point with overlaps (negative tag width) or 2 separate points for stop and start?
Start and end points were distinctly different. IIRC, the algorithm insisted that the entire profile be traversed by the tool and took into account the direction of travel. So if you accidentally, set the exit point on the wrong side of the entry point relative to travel, it could cause most of the path to be traversed twice. I think it would start at the start point and go all the way around to the start point and then look for the exit point.
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Post by pauluzs »

Taking as an example your image below with an outside contour and five inside contours. Each of the inside contours is a wire with one or more edges and the CNC must rapid between them. If the user picks five points to identify start points, you must keep track of which point corresponds to which wire
IMO It's the user that picks the startpoint on the base Operation what is the original Startpoint, All toolpaths (except engrave&deburr) have this setting.In most cases that would be the tool-change position or end of previous op. For this you will need to pick a point in free space.

This dressup would move the engagement points (were rapids become moves) along that baseOp path, which would be one continuous wire already containing the beginning and ending of all contours in separated by rapids. In the Tag code: isEntryOrExitStrut. This way we don't have to track them just recalculate.

The LeadInOut does somewhat similar, it finds these engagement points and lets you modify them. it also applies multiple times in one OP. When splitting into EntryStud(Start engagement) and ExitStud (End engagement) there's a piece we either miss or double cut in 2D. In 2,5/3D there is a height difference and requires them to be treated different anyway. Being able to control how engagement ends ie: moving in on pocket bottom or after a overhang cut before moving up is actually a leadOUT
User avatar
pl7i92LCNC
Posts: 208
Joined: Tue Mar 12, 2019 3:03 pm
Location: RLP DE

Re: Start Points and order in face based toolpaths

Post by pl7i92LCNC »

doesent this give a Memory brek on big parts as we got alot of People working on 8-10meter Parts
Foam or concrete

spliting in 2 Parts is the way Heeks does it
https://github.com/danielfalck/libarea/ ... /kurve.cpp
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Start Points and order in face based toolpaths

Post by m0n5t3r »

not sure this is the right thread, but... I got some time to build things again, Path has improved a lot in the mean time, but one thing is unchanged
Screenshot from 2019-03-14 21-32-18.png
Screenshot from 2019-03-14 21-32-18.png (19.93 KiB) Viewed 1544 times
since I had something more important to do, I dug into it a little and found a way to use my old code that survived in PathUtils.sort_jobs:
Screenshot from 2019-03-14 21-01-09.png
Screenshot from 2019-03-14 21-01-09.png (16.17 KiB) Viewed 1544 times
code is at https://github.com/m0n5t3r/FreeCAD/comm ... 8c5acc21a4

I'm not sure it's the right place to put it (and I have no idea by what magic PathHelix sorts holes, because my old code doesn't seem to be used in there and there is nothing that looks like sorting to be seen).

It seems to handle overlapping shapes reasonably well (at least better than no sorting whatsoever):
Screenshot from 2019-03-14 22-09-33.png
Screenshot from 2019-03-14 22-09-33.png (18.32 KiB) Viewed 1544 times
If PathAreaOp is the right place for this I'll play around some more (maybe it's better to calculate the center of the shape instead of [XMin, YMin], or to run the operation twice - first time to get start and end points, second time to sort based on those, because I have no idea how why it decides to start on the furthest point from origin...)
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Start Points and order in face based toolpaths

Post by sliptonic »

m0n5t3r wrote: Thu Mar 14, 2019 8:15 pm not sure this is the right thread, but... I got some time to build things again, Path has improved a lot in the mean time, but one thing is unchanged

...

If PathAreaOp is the right place for this I'll play around some more (maybe it's better to calculate the center of the shape instead of [XMin, YMin], or to run the operation twice - first time to get start and end points, second time to sort based on those, because I have no idea how why it decides to start on the furthest point from origin...)
Can you please include your test file so it's possible to compare apples to apples?
m0n5t3r
Posts: 137
Joined: Fri Feb 03, 2017 2:55 pm

Re: Start Points and order in face based toolpaths

Post by m0n5t3r »

if by test you mean freecad file, here it is:
quadcopter1.FCStd
(839.57 KiB) Downloaded 50 times
(I have no idea how I could ever unit test this)
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Post by pauluzs »

mlampert wrote: Mon Mar 11, 2019 7:55 pm Personally I would very much appreciate a starting point implementation - I would use that a lot :)
For the Operation startpoint only how about something like this?

For startpoints on the toolpath just run as is.

If you want a startpoint outside the solid set your stock appearance to either: Flat Lines, or Shaded

Updated: 19 March
added FixedZ (Fixes Z at 0)
Added ExtraHeight (Add's extra Z height)
Added Automatic selection when not LockedToToolPath (First click Path then click startpoint)
Added Done() to end selection when in loop

Code: Select all


view=Gui.activeDocument().activeView()
doc = Gui.ActiveDocument.Document.Name

LockedToToolPath = True
LoopSelection = True
FixedZ = False
ExtraHeight = 0

if (LockedToToolPath == True):
	FreeCAD.Console.PrintMessage("\nSelect Startpoint: \n")
else:
	FreeCAD.Console.PrintMessage("\nSelect Operation: \n")

def BaseOp(PreSelection):
	if('Dressup' in (PreSelection.ObjectName) and hasattr( (PreSelection.Object.Base), 'Base')):
#	if('Dressup' in (PreSelection.ObjectName)):

		if('Dressup' in ( PreSelection.Object.Base.Name) ):#Double Dressup
			if('Dressup' in ( PreSelection.Object.Base.Base.Name) ):#Triple Dressup
				return PreSelection.Object.Base.Base.Base.Name#Triple Dressup
			return PreSelection.Object.Base.Base.Name#Double Dressup
		else:
			return PreSelection.Object.Base.Name#Single Dressup
	else:
		return PreSelection.ObjectName#No Dressup

def setLocked(ObjectName, PickedPoints):
	FreeCAD.getDocument(doc).getObject(ObjectName).UseStartPoint = True
	FreeCAD.getDocument(doc).getObject(ObjectName).StartPoint = (PickedPoints[0], PickedPoints[1],((PickedPoints[2]+ExtraHeight)* (not FixedZ))+( ExtraHeight* FixedZ))
	App.activeDocument().recompute()
	FreeCAD.Console.PrintMessage(" \nSet Startpoint for: ")	
	FreeCAD.Console.PrintMessage(ObjectName)
	FreeCAD.Console.PrintMessage(("At:  X ",PickedPoints[0],"Y",PickedPoints[1],"Z",((PickedPoints[2]+ExtraHeight)* (not FixedZ))+( ExtraHeight* FixedZ)))
	FreeCAD.Console.PrintMessage(" \n ")	

	if(LoopSelection == False):
		view.removeEventCallback("SoMouseButtonEvent",c)

def setUnLocked(ObjectName, PickedPoints):
	if(hasattr (FreeCAD.getDocument(doc).getObject(ObjectName), 'UseStartPoint')):
		FreeCAD.getDocument(doc).getObject(ObjectName).UseStartPoint = True
		FreeCAD.getDocument(doc).getObject(ObjectName).StartPoint = (PickedPoints[0], PickedPoints[1],((PickedPoints[2]+ExtraHeight)* (not FixedZ))+( ExtraHeight* FixedZ))
		App.activeDocument().recompute()
		FreeCAD.Console.PrintMessage(" \nSet UnLocked Startpoint for:")
		FreeCAD.Console.PrintMessage(ObjectName)
		FreeCAD.Console.PrintMessage(("At:  X ",PickedPoints[0],"Y",PickedPoints[1],"Z",((PickedPoints[2]+ExtraHeight)* (not FixedZ))+( ExtraHeight* FixedZ)))
		FreeCAD.Console.PrintMessage(" \n ")	

	if(LoopSelection == False):
		view.removeEventCallback("SoMouseButtonEvent",c)

def Done():
	view.removeEventCallback("SoMouseButtonEvent",c)
	FreeCAD.Console.PrintMessage("\nDone Setting startpoints\n")

class ViewObserver():
	def getClicked(self, info):
		down = (info["State"] == "DOWN")
		PreSelection = Gui.Selection.getPreselection()
		ObjectName = BaseOp(PreSelection)
		PickedPoints = PreSelection.PickedPoints[0]
		if (down):
			if ( hasattr (FreeCAD.getDocument(doc).getObject(ObjectName), 'UseStartPoint') ):
				if (LockedToToolPath == True):
					setLocked(ObjectName, PickedPoints)
			else:
				if (LockedToToolPath == False):
					setUnLocked(Gui.Selection.getSelection().__getitem__(0).Name, PickedPoints)
				else:
					FreeCAD.Console.PrintMessage(" \n")			
					FreeCAD.Console.PrintMessage(ObjectName)
					FreeCAD.Console.PrintMessage(" Has no atribute: UseStartPoint\n")

o = ViewObserver()
c = view.addEventCallback("SoMouseButtonEvent",o.getClicked)

LockedToToolPath = False
LoopSelection = True
FixedZ = False
ExtraHeight = 0 

Last edited by pauluzs on Tue Mar 19, 2019 10:03 am, edited 7 times in total.
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Post by pauluzs »

Now we have a nice visualization what happens when just setting a Startpoint for one Operation with many engagement points.
In my case this in not the desired behavior.
Attachments
Screenshot from 2019-03-15 01-42-19.png
Screenshot from 2019-03-15 01-42-19.png (268.36 KiB) Viewed 1512 times
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Post by pauluzs »

Had some time again and updated the Startpoint picker from 2 posts above, for single engagement-point operations this works well.
Also it produces less screen clutter(on parts with many ops) as a screen full of green spheres like the holdingtag gui does.
sliptonic wrote:
Does it's behavior match what #3481 needs for 3d parts as well?

Done some test on m0n5t3r 's file as well as on some of my own. The problem could be solved if we tooled each feature separate, so each engagement would be it's own operation for which a startpoint can be set.

Next up my list is to have this somehow automated, not having to select each hole and dressups separate. While gaining some control over where the initial startpoint will be.
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: Start Points and order in face based toolpaths

Post by mlampert »

pauluzs wrote: Tue Mar 19, 2019 10:39 am Next up my list is to have this somehow automated, not having to select each hole and dressups separate. While gaining some control over where the initial startpoint will be.
This is great - I saw a PR being merged shortly which will sort all feature processing according to their position. It'll change behaviour quite a bit so an automatic selection makes a lot of sense.
Post Reply