def inoutprofile(self): if self.depth == 0: offset = -self.diameter / 2.0 else: offset = -self.diameter*self.stepover self.OutOffsetPathList = [] for path in self.outpaths : p1=p2=None if len(path)>0: p1 = path[0].A dir = path.direction() opath = path.offset(offset*float(dir)) opath.intersectSelf() opath.removeExcluded(path, abs(offset)) if len(opath)>0: p2 = opath[0].A self.OutOffsetPathList.append(opath) if self.depth >0 and p1 is not None: self.outPathG1SegList.append(Segment(Segment.LINE,p1,p2)) self.islandOffPaths = [] for island in self.insideIslandList : p3=p4=None if len(island)>0: p3 = island[0].A dir = island.direction() offIsl = island.offset(-offset*float(dir)) if len(offIsl)>0: p4 = offIsl[0].A if self.depth >0 and p3 is not None and p4 is not None : self.islandG1SegList.append(Segment(Segment.LINE,p3,p4)) offIsl.intersectSelf() offIsl.removeExcluded(island, abs(offset)) self.islandOffPaths.append(offIsl)
def inoutprofile(self): if self.depth == 0: self.offset = -self.diameter / 2.0 +self.AdditionalCut self.offsetLastPass = self.offset else: self.offset = -self.diameter*self.stepover self.offsetLastPass = -min(self.diameter*self.stepover/2.,self.diameter*0.49) self.OutOffsetPathList = [] for path in self.outpaths : p1=p2=None if len(path)>0: p1 = path[0].A if self.depth == 0 : path.directionSet(self.selectCutDir*float(self.profiledir)) direct = path.direction() opathCopy = path.offset(self.profiledir*self.offset*float(direct)) points = opathCopy.intersectSelf() opathCopy.removeExcluded(path, abs(self.offset)) if len(opathCopy)>0: #there remains some path after full offset : not the last pass opath = path.offset(self.profiledir*self.offset*float(direct)) offset = self.offset else:# nothing remaining after the last pass => apply offsetLastPass opath = path.offset(self.profiledir*self.offsetLastPass*float(direct)) offset = self.offsetLastPass opath.intersectSelf() if len (opath)>0 : opath.removeExcluded(path, abs(offset)) opath.removeZeroLength(abs(self.diameter)/100.) # opath.removeZeroLength(abs(EPS*10.)) opath.convert2Lines(abs(self.diameter)/10.) if self.depth == 0 and self.Overcuts : opath.overcut(self.profiledir*self.offset*float(direct)) if len(opath)>0: p2 = opath[0].A self.OutOffsetPathList.append(opath) if self.depth >0 and p1 is not None: self.outPathG1SegList.append(Segment(Segment.LINE,p1,p2)) self.islandOffPaths = [] for island in self.insideIslandList : p3=p4=None if len(island)>0: p3 = island[0].A if self.depth == 0 : island.directionSet(-self.selectCutDir*float(self.profiledir)) direct = island.direction() offIsl = island.offset(-self.profiledir*self.offset*float(direct)) offIsl.intersectSelf() if len(offIsl)>0 : offIsl.removeExcluded(island, abs(self.offset)) offIsl.removeZeroLength(abs(self.diameter)/100.) # offIsl.removeZeroLength(abs(EPS*10.)) offIsl.convert2Lines(abs(self.diameter)/10.) if len(offIsl)>0: p4 = offIsl[0].A if self.depth >0 and p3 is not None and p4 is not None : self.islandG1SegList.append(Segment(Segment.LINE,p3,p4)) if self.depth == 0 and self.Overcuts : offIsl.overcut(-self.profiledir*self.offset*float(direct)) self.islandOffPaths.append(offIsl)
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