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.
User avatar
sliptonic
Posts: 1562
Joined: Tue Oct 25, 2011 10:46 pm

Re: Start Points and order in face based toolpaths

Postby sliptonic » Tue Mar 19, 2019 8:48 pm

pauluzs wrote:
Tue Mar 19, 2019 10:39 am
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?
If I understand correctly, then yes. I'll be happy to take a closer look. Is your code in a git branch so it can be pulled and tested directly?
pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Postby pauluzs » Wed Mar 20, 2019 7:52 pm

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.
Have to look into that, do you happen to have the PR#?
If I understand correctly, then yes. I'll be happy to take a closer look. Is your code in a git branch so it can be pulled and tested directly?
It doesn't have it's own branch, ATM i just paste the code from a few post back in the python console. If this is about the desired behavior in milling as well, i don't mind making translations, buttons and a GUI element. Al tough that will be after i figured out the algorithmic placement and have a decent working leadinout, for me being able to tool fast, simple and get a decent program has the first priority now.
mlampert
Posts: 1337
Joined: Fri Sep 16, 2016 9:28 pm

Re: Start Points and order in face based toolpaths

Postby mlampert » Wed Mar 20, 2019 8:08 pm

pauluzs
Posts: 27
Joined: Wed Feb 27, 2019 7:48 pm
Location: Netherlands

Re: Start Points and order in face based toolpaths

Postby pauluzs » Thu Mar 21, 2019 1:59 am

Thanks

New shorthand, cleanded up version, now also works on dressups when LockedToToolPath = False

Code: Select all

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

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

FreeCAD.Console.PrintMessage("\nSelect Startpoint or Operation\n")

def BaseOp(Object):
	if('Dressup' in (Object.Name) and hasattr( (Object.Base), 'Base')):
		if('Dressup' in ( Object.Base.Name) ):#Double Dressup
			if('Dressup' in ( Object.Base.Base.Name) ):#Triple Dressup
				return Object.Base.Base.Base.Name#Triple Dressup
			return Object.Base.Base.Name#Double Dress up
		else:
			return Object.Base.Name#Single Dressup
	else:
		return Object.Name#No Dressup

def SetStartPoint(Object, PickedPoints):
	FreeCAD.getDocument(doc).getObject(Object).UseStartPoint = True
	FreeCAD.getDocument(doc).getObject(Object).StartPoint = (PickedPoints[0], PickedPoints[1],((PickedPoints[2]+ExtraHeight)* (not FixedZ))+( ExtraHeight* FixedZ))
	App.activeDocument().recompute()
	FreeCAD.Console.PrintMessage(" \nSet Startpoint for: ")	
	FreeCAD.Console.PrintMessage(Object)
	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",Callback)

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

class ViewObserver():
	def GetClicks(self, info):
		down = (info["State"] == "DOWN")
		PreSelection = Gui.Selection.getPreselection()
		Object = BaseOp(PreSelection.Object)
		PickedPoints = PreSelection.PickedPoints[0]
		if (down):
			if ( hasattr (FreeCAD.getDocument(doc).getObject(Object), 'UseStartPoint') ):
				if (LockedToToolPath == True):
					SetStartPoint(Object, PickedPoints)
					FreeCAD.Console.PrintMessage("\nSelect Startpoint or Operation\n")
			else:
				if (LockedToToolPath == False and (Gui.Selection.getSelection().__len__() > 0)):
					Object = BaseOp(Gui.Selection.getSelection().__getitem__(0))
					if ( hasattr (FreeCAD.getDocument(doc).getObject(Object), 'UseStartPoint') ):
						SetStartPoint(Object, PickedPoints)
						FreeCAD.Console.PrintMessage("\nSelect Startpoint or Operation\n")
					else:
						FreeCAD.Console.PrintMessage(" \n")			
						FreeCAD.Console.PrintMessage(Object)
						FreeCAD.Console.PrintMessage(" Has no atribute: UseStartPoint\n")
				else:
					FreeCAD.Console.PrintMessage(" \n")			
					FreeCAD.Console.PrintMessage(Object)
					FreeCAD.Console.PrintMessage(" Has no atribute: UseStartPoint\n")

Observer = ViewObserver()
Callback = view.addEventCallback("SoMouseButtonEvent",Observer.GetClicks)

LockedToToolPath = False
LoopSelection = True
FixedZ = False
ExtraHeight = 0 
RatonLaveur
Posts: 341
Joined: Wed Mar 27, 2019 10:45 am

Re: Start Points and order in face based toolpaths

Postby RatonLaveur » Tue May 28, 2019 8:09 am

Hello Gents,

reviving this otherwise really interesting thread instead of making a new one.

I'm in the process of producing 2D parts with requirement of high accuracy, and therefore I need to control my start points with ease.
Specifically, I need to create Lead-In (no Lead-Out required but it does not matter). The current LeadIn dress-up is not working so well, or I'm very inept at using it, mostly I lament the seemingly impossible selection of whether the lead-in should be from inside or outside the tool-path.

Hence my current solution is to create a half circle indepent sketch (lead-in) and use Path FromShape to create the lead-in. The lead-in can be arbitrarily set inside or outside by mapping the half circle sketch reversed.

But I need the start point for the profile to coincide with the end of the lead-in. Now I could learn the position (or approximate position) of the vertex and manually input that. But I was hoping there'd be a better way.

Has anyone solved this yet?
Attachments
Lead_in dressup not adequate.png
Lead_in dressup not adequate.png (7.41 KiB) Viewed 79 times
Lead-in manually set by sketch.png
Lead-in manually set by sketch.png (2.17 KiB) Viewed 79 times
Startpoint doesn't coincide between profile and end of leadin.png
Startpoint doesn't coincide between profile and end of leadin.png (1.96 KiB) Viewed 79 times