Ejemplo n.º 1
0
	def removeOutOfProfile(self):
		self.NewPaths = []
		newoutpath = Path("path")
		for path in self.OutOffsetPathList: 
			for seg in path:
				newoutpath.append(seg)
		for OutoffsetPath in self.OutOffsetPathList:
			for path in self.IntersectedIslands :
				for seg in path :
					inside = not OutoffsetPath.isSegInside(seg)==-1
					if inside:
						newoutpath.append(seg)
		purgednewoutpath= newoutpath.split2contours()#list of paths
		self.NewPaths.extend(purgednewoutpath)
Ejemplo n.º 2
0
	def removeInsideIslands(self):
		self.CleanPath = []
		cleanpath = Path("Path")
		for path in self.NewPaths :
			for seg in path :
				inside = False
				for island in self.IntersectedIslands :
					issegin = island.isSegInside(seg)==1
					if issegin:
						if not seg in island:
							inside = True
							break
				if not inside:
					cleanpath.append(seg)
		cleanpath = cleanpath.split2contours()
		self.CleanPath.extend(cleanpath)
Ejemplo n.º 3
0
def pocket(selectedblocks, RecursiveDepth,ProfileDir,CutDir,AdditionalCut,Overcuts, CustomRecursiveDepth,
		ignoreIslands,
		allowG1, diameter, stepover, name,gcode,app):
	undoinfo = []
	msg = ""
	newblocks = []
	allblocks = gcode.blocks
	islandslist = []
	outpathslist= []
	ignoreIslandschoicedict = {
		"Regard all islands except tabs":0,
		"Ignore all islands":1,
		"Regard only selected islands":2,
		}
	ignoreIslandschoice = ignoreIslandschoicedict.get(ignoreIslands,0)
	for bid,block in enumerate(allblocks):#all blocks
		if block.operationTest('island')and not block.operationTest('tab'):
			if ignoreIslandschoice==0:
				for islandPath in gcode.toPath(bid):
					islandslist.append(islandPath)
	for bid in reversed(selectedblocks):#selected blocks
		if allblocks[bid].name() in ("Header", "Footer"): continue
		newpath = []
		block = allblocks[bid]
		if block.operationTest('island')and not block.operationTest('tab') and ignoreIslandschoice==2:
			for islandPath in gcode.toPath(bid):
				islandslist.append(islandPath)
		for path in gcode.toPath(bid):
			if not path.isClosed():
				m = "Path: '%s' is OPEN"%(path.name)
				if m not in msg:
					if msg: msg += "\n"
					msg += m
				path.close()
			# Remove tiny segments
			path.removeZeroLength(abs(diameter)/100.)
			# Convert very small arcs to lines
			path.convert2Lines(abs(diameter)/10.)
			if not block.operationTest('island'):
				outpathslist.append(path)
		MyPocket = PocketIsland(outpathslist,RecursiveDepth,ProfileDir,CutDir,AdditionalCut,
							Overcuts,CustomRecursiveDepth,
							ignoreIslands,
							allowG1,diameter,stepover,0,app,islandslist)
		newpathList =  MyPocket.getfullpath()
		#concatenate newpath in a single list and split2contours
		if allowG1 :
			MyFullPath = Path("Pocket")
			for path in newpathList :
				for seg in path:
					MyFullPath.append(seg)
			newpathList = MyFullPath.split2contours()
		if newpathList:
			# remember length to shift all new blocks
			# the are inserted before
			before = len(newblocks)
			undoinfo.extend(gcode.importPath(bid+1, newpathList,
				newblocks, True, False))
			new = len(newblocks)-before
			for i in range(before):
				newblocks[i] += new
			allblocks[bid].enable = False
	gcode.addUndo(undoinfo)
	# return new blocks inside the blocks list
	del selectedblocks[:]
	selectedblocks.extend(newblocks)
	return msg
Ejemplo n.º 4
0
def pocket(blocks, allowG1, diameter, stepover, name,gcode,items):
	undoinfo = []
	msg = ""
	newblocks = []

	islandslist = []
	for bid,block in enumerate(gcode.blocks):
		if block.operationTest('island'):
			for islandPath in gcode.toPath(bid):
				islandslist.append(islandPath)
	for bid in reversed(blocks):
		if gcode.blocks[bid].name() in ("Header", "Footer"): continue
		newpath = []
		for path in gcode.toPath(bid):
			if not path.isClosed():
				m = "Path: '%s' is OPEN"%(path.name)
				if m not in msg:
					if msg: msg += "\n"
					msg += m
				path.close()

			# Remove tiny segments
			path.removeZeroLength(abs(diameter)/100.)
			# Convert very small arcs to lines
			path.convert2Lines(abs(diameter)/10.)

			path.directionSet(1) #turn path to CW (conventional when milling inside)

			D = path.direction()
			if D==0: D=1

			remove = ["cut","reverse","climb","conventional","cw","ccw","pocket"]
			if name is None:
				path.name = Block.operationName(path.name, "pocket,conventional,cw", remove)
			else:
				path.name = Block.operationName(path.name, name, remove)
			MyPocket = PocketIsland([path],allowG1,diameter,stepover,0,islandslist)
			newpathList =  MyPocket.getfullpath()
			#concatenate newpath in a single list and split2contours
			if allowG1 :
				MyFullPath = Path("Pocket")
				for path in newpathList :
					for seg in path:
						MyFullPath.append(seg)
				newpathList = MyFullPath.split2contours()
		if newpathList:
			# remember length to shift all new blocks
			# the are inserted before
			before = len(newblocks)
			undoinfo.extend(gcode.importPath(bid+1, newpathList,
				newblocks, True, False))
			new = len(newblocks)-before
			for i in range(before):
				newblocks[i] += new
			gcode.blocks[bid].enable = False
	gcode.addUndo(undoinfo)

	# return new blocks inside the blocks list
	del blocks[:]
	blocks.extend(newblocks)
	return msg