def review(obj): "checks the selected job for common errors" toolcontrolcount = 0 if len(obj.Tooltable.Tools) == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Machine: " + str(obj.Label) + " has no tools defined in the tool table\n")) if obj.X_Max == obj.X_Min or obj.Y_Max == obj.Y_Min: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n")) for item in obj.Group: print "Checking: " + item.Label if item.Name[:2] == "TC": toolcontrolcount += 1 if item.ToolNumber == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using ID 0 which the undefined default. Please set a real tool.\n")) else: tool = PU.getTool(item, item.ToolNumber) if tool is None: FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which is invalid\n")) elif tool.Diameter == 0: FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which has a zero diameter\n")) if item.HorizFeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Horizontal feed rate\n")) if item.VertFeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Vertical feed rate\n")) if item.SpindleSpeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the spindle speed\n")) if toolcontrolcount == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "A Tool Controller was not found. Default values are used which is dangerous. Please add a Tool Controller.\n"))
def setup(self, obj, generate=None): print("setup") self.obj = obj try: pathData = PathData(obj) except ValueError: FreeCAD.Console.PrintError(translate("PathDressup_HoldingTags", "Cannot insert holding tags for this path - please select a Profile path\n")) return None self.toolRadius = 5 toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.toolRadius = 5 else: tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if not tool or tool.Diameter == 0: self.toolRadius = 5 else: self.toolRadius = tool.Diameter / 2 self.pathData = pathData if generate: obj.Height = self.pathData.defaultTagHeight() obj.Width = self.pathData.defaultTagWidth() obj.Angle = self.pathData.defaultTagAngle() self.generateTags(obj, generate) return self.pathData
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" output += "(remote gcode goes here)" path = Path.Path(output) obj.Path = path
def setup(self, obj): PathLog.info("Here we go ... ") if hasattr(obj.Base, "BoneBlacklist"): # dressing up a bone dressup obj.Side = obj.Base.Side else: # otherwise dogbones are opposite of the base path's side if obj.Base.Side == Side.Left: obj.Side = Side.Right elif obj.Base.Side == Side.Right: obj.Side = Side.Left else: # This will cause an error, which is fine for now 'cause I don't know what to do here obj.Side = 'On' self.toolRadius = 5 toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.toolRadius = 5 else: tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if not tool or tool.Diameter == 0: self.toolRadius = 5 else: self.toolRadius = tool.Diameter / 2 self.shapes = {} self.dbg = []
def setup(self, obj): debugPrint("Here we go ... ") if hasattr(obj.Base, "BoneBlacklist"): # dressing up a bone dressup obj.Side = obj.Base.Side else: # otherwise dogbones are opposite of the base path's side if obj.Base.Side == Side.Left: obj.Side = Side.Right elif obj.Base.Side == Side.Right: obj.Side = Side.Left else: # This will cause an error, which is fine for now 'cause I don't know what to do here obj.Side = 'On' self.toolRadius = 5 toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.toolRadius = 5 else: tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if not tool or tool.Diameter == 0: self.toolRadius = 5 else: self.toolRadius = tool.Diameter / 2 self.shapes = {} self.dbg = []
def review(obj): "checks the selected project for common errors" toolcontrolcount = 0 for item in obj.Group: print "Checking: " + item.Label if item.Name[:2] == "TC": toolcontrolcount += 1 if item.ToolNumber == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using ID 0 which the undefined default. Please set a real tool.\n")) else: tool = PU.getTool(item, item.ToolNumber) if tool is None: FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which is invalid\n")) elif tool.Diameter == 0: FreeCAD.Console.PrintError(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " is using tool: " + str(item.ToolNumber) + " which has a zero diameter\n")) if item.HorizFeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Horizontal feed rate\n")) if item.VertFeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the Vertical feed rate\n")) if item.SpindleSpeed == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the spindle speed\n")) if item.Name[:7] == "Machine": if len(item.Tooltable.Tools) == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Machine: " + str(item.Label) + " has no tools defined in the tool table\n")) if item.X_Max == item.X_Min or item.Y_Max == item.Y_Min: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n")) if toolcontrolcount == 0: FreeCAD.Console.PrintWarning(translate("Path_Sanity", "A Tool Controller was not found. Default values are used which is dangerous. Please add a Tool Controller.\n"))
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" output += "(remote gcode goes here)" path = Path.Path(output) obj.Path = path
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if not tool or tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name self.setLabel(obj) output += "(" + obj.Label + ")" if not obj.UseComp: output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" parentJob = PathUtils.findParentJob(obj) if parentJob is None: return baseobject = parentJob.Base if baseobject is None: return contourwire = TechDraw.findShapeOutline(baseobject.Shape,1, Vector(0,0,1)) edgelist = contourwire.Edges edgelist = Part.__sortEdges__(edgelist) try: output += self._buildPathLibarea(obj, edgelist) except: FreeCAD.Console.PrintError("Something unexpected happened. Unable to generate a contour path. Check project and tool config.") if obj.Active: path = Path.Path(output) obj.Path = path if obj.ViewObject: obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self,obj): if obj.Base: # tie the toolnumber to the PathLoadTool object ToolNumber if len(obj.InList)>0: #check to see if obj is in the Project group yet project = obj.InList[0] tl = int(PathUtils.changeTool(obj,project)) obj.ToolNumber= tl tool = PathUtils.getTool(obj,obj.ToolNumber) if tool: self.radius = tool.Diameter/2 else: # temporary value,in case we don't have any tools defined already self.radius = 0.25 # self.radius = 0.25 self.clearance = obj.ClearanceHeight.Value self.step_down=obj.StepDown.Value self.start_depth=obj.StartDepth.Value self.final_depth=obj.FinalDepth.Value self.rapid_safety_space=obj.RetractHeight.Value self.side=obj.Side self.offset_extra=obj.OffsetExtra.Value self.use_CRC=obj.UseComp self.vf=obj.VertFeed.Value self.hf=obj.HorizFeed.Value edgelist = [] if obj.StartPtName and obj.UseStartPt: self.startpt = FreeCAD.ActiveDocument.getObject(obj.StartPtName).Shape else: self.startpt = None if obj.EndPtName and obj.UseEndPt: self.endpt = FreeCAD.ActiveDocument.getObject(obj.EndPtName).Shape else: self.endpt = None for e in obj.Edgelist: edgelist.append(FreeCAD.ActiveDocument.getObject(obj.Base[0].Name).Shape.Edges[e-1]) output=PathKurveUtils.makePath(edgelist,self.side,self.radius,self.vf,self.hf,self.offset_extra, \ self.rapid_safety_space,self.clearance,self.start_depth,self.step_down, \ self.final_depth,self.use_CRC,obj.Direction,self.startpt,self.endpt) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" if obj.Comment != "": output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: output += "G0 Z" + PathUtils.fmt(obj.ClearanceHeight.Value)+"\n" wires = [] for o in obj.Base: # we only consider the outer wire if this is a Face for w in o[0].Shape.Wires: tempedges = PathUtils.cleanedges(w.Edges, 0.5) wires.append (Part.Wire(tempedges)) if obj.Algorithm == "OCC Native": output += self.buildpathocc(obj, wires) output += "G0 Z" + PathUtils.fmt(obj.ClearanceHeight.Value)+"\n" # print output if output == "": output += "(No commands processed)" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def refresh(self): obj = FreeCADGui.Selection.getSelection()[0] values = {} for i in obj.PropertiesList: if obj.getGroupOfProperty(i) in ["Remote"]: values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Depth"]: print str(i) values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Step"]: values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Tool"]: tool = PathUtils.getTool(obj, obj.ToolNumber) if tool: tradius = tool.Diameter / 2 tlength = tool.LengthOffset ttype = tool.ToolType else: tradius = 0.25 tlength = 1 ttype = "undefined" values.update({"tool_diameter": tradius}) values.update({"tool_length": tlength}) values.update({"tool_type": ttype}) payload = json.dumps(values) url = obj.URL + "/api/v1.0/path" print url try: req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') response = urllib2.urlopen(req, payload) data = json.load(response) except: print "service not defined or not responding" return path = data['path'] output = "" for command in path: output += command['command'] path = Path.Path(output) obj.Path = path
def refresh(self): obj = FreeCADGui.Selection.getSelection()[0] values = {} for i in obj.PropertiesList: if obj.getGroupOfProperty(i) in ["Remote"]: values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Depth"]: print str(i) values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Step"]: values.update({i: obj.getPropertyByName(i)}) if obj.getGroupOfProperty(i) in ["Tool"]: tool = PathUtils.getTool(obj, obj.ToolNumber) if tool: tradius = tool.Diameter/2 tlength = tool.LengthOffset ttype = tool.ToolType else: tradius = 0.25 tlength = 1 ttype = "undefined" values.update({"tool_diameter": tradius}) values.update({"tool_length": tlength}) values.update({"tool_type": ttype}) payload = json.dumps(values) url = obj.URL + "/api/v1.0/path" print url try: req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') response = urllib2.urlopen(req, payload) data = json.load(response) except: print "service not defined or not responding" return path = data['path'] output = "" for command in path: output += command['command'] path = Path.Path(output) obj.Path = path
def execute(self, obj): output = "" if obj.Comment != "": output += "(" + str(obj.Comment) + ")\n" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: for o in obj.Base: output += "G0 " + str(obj.ClearanceHeight.Value) + "\n" # we only consider the outer wire if this is a Face wires = o[0].Shape.Wires if obj.Algorithm == "OCC Native": output += self.buildpathocc(obj, wires) # print output if output == "": output += "G0" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def Activated(self): import FreeCADGui import Path from PathScripts import PathUtils FreeCAD.ActiveDocument.openTransaction( translate("PathHelix", "Create a helix cut")) FreeCADGui.addModule("PathScripts.PathHelix") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "PathHelix") ObjectPathHelix(obj) ViewProviderPathHelix(obj.ViewObject) obj.Features = cylinders_in_selection() obj.DeltaR = 1.0 toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is not None: obj.ToolNumber = toolLoad.ToolNumber tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool: # start with 25% overlap obj.DeltaR = tool.Diameter * 0.75 obj.Active = True obj.Comment = "" obj.Direction = "CW" obj.StartSide = "inside" obj.Clearance = 10.0 obj.StepDown = 1.0 obj.UseStartDepth = False obj.StartDepth = 1.0 obj.UseFinalDepth = False obj.FinalDepth = 0.0 obj.ThroughDepth = 0.0 PathUtils.addToJob(obj) obj.ViewObject.startEditing() FreeCAD.ActiveDocument.recompute()
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name output += "(" + obj.Label + ")" output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name output += "(" + obj.Label + ")" output += "(Compensated Tool Path. Diameter: " + str( self.radius * 2) + ")" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" if obj.Comment != "": output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(remote gcode goes here)" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" if obj.Comment != "": output += '(' + str(obj.Comment) + ')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(remote gcode goes here)" if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horiRrapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name output += "(" + obj.Label + ")" if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: for b in obj.Base: for sub in b[1]: import Part import PathScripts.PathKurveUtils if "Face" in sub: shape = getattr(b[0].Shape, sub) wire = shape.OuterWire edges = wire.Edges else: edges = [getattr(b[0].Shape, sub) for sub in b[1]] wire = Part.Wire(edges) shape = None # output = "" if obj.Algorithm == "OCC Native": if shape is None: shape = wire output += self.buildpathocc(obj, shape) else: try: import area except: FreeCAD.Console.PrintError(translate("PathKurve", "libarea needs to be installed for this command to work.\n")) return a = area.Area() if shape is None: c = PathScripts.PathKurveUtils.makeAreaCurve(wire.Edges, 'CW') a.append(c) else: for w in shape.Wires: c = PathScripts.PathKurveUtils.makeAreaCurve(w.Edges, 'CW') a.append(c) a.Reorder() output += self.buildpathlibarea(obj, a) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import MeshPart FreeCAD.Console.PrintWarning( translate("PathSurface", "Hold on. This might take a minute.\n")) output = "" if obj.Comment != "": output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" # if obj.Base: # for b in obj.Base: parentJob = PathUtils.findParentJob(obj) if parentJob is None: return mesh = parentJob.Base if mesh is None: return print "base object: " + mesh.Name if obj.Algorithm in ['OCL Dropcutter', 'OCL Waterline']: try: import ocl except: FreeCAD.Console.PrintError(translate( "PathSurface", "This operation requires OpenCamLib to be installed.\n")) return #mesh = b[0] if mesh.TypeId.startswith('Mesh'): mesh = mesh.Mesh bb = mesh.BoundBox else: bb = mesh.Shape.BoundBox mesh = MeshPart.meshFromShape(mesh.Shape, MaxLength=2) s = ocl.STLSurf() for f in mesh.Facets: p = f.Points[0] q = f.Points[1] r = f.Points[2] t = ocl.Triangle(ocl.Point(p[0], p[1], p[2]), ocl.Point( q[0], q[1], q[2]), ocl.Point(r[0], r[1], r[2])) s.addTriangle(t) if obj.Algorithm == 'OCL Dropcutter': output = self._dropcutter(obj, s, bb) elif obj.Algorithm == 'OCL Waterline': output = self._waterline(obj, s, bb) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: hfaces = [] vfaces = [] wires = [] for b in obj.Base: # we only consider the outer wire if this is a Face # Horizontal and vertical faces are handled differently shape = getattr(b[0].Shape, b[1]) if abs(shape.normalAt(0, 0).z) == 1: # horizontal face hfaces.append(shape) elif abs(shape.normalAt(0, 0).z) == 0: # vertical face vfaces.append(shape) for h in hfaces: wires.append(h.OuterWire) tempshell = Part.makeShell(vfaces) slices = tempshell.slice(FreeCAD.Base.Vector(0, 0, 1), tempshell.CenterOfMass.z) wires = wires + slices for wire in wires: if obj.Algorithm == "OCC Native": output += self._buildPathOCC(obj, wire) else: try: import area except: FreeCAD.Console.PrintError( translate( "Path", "libarea needs to be installed for this command to work.\n" )) return edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import MeshPart FreeCAD.Console.PrintWarning( translate("PathSurface", "Hold on. This might take a minute.\n")) output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: for b in obj.Base: if obj.Algorithm in ['OCL Dropcutter', 'OCL Waterline']: try: import ocl except: FreeCAD.Console.PrintError(translate( "PathSurface", "This operation requires OpenCamLib to be installed.\n")) return mesh = b[0] if mesh.TypeId.startswith('Mesh'): mesh = mesh.Mesh bb = mesh.BoundBox else: bb = mesh.Shape.BoundBox mesh = MeshPart.meshFromShape(mesh.Shape, MaxLength=2) s = ocl.STLSurf() for f in mesh.Facets: p = f.Points[0] q = f.Points[1] r = f.Points[2] t = ocl.Triangle(ocl.Point(p[0], p[1], p[2]), ocl.Point( q[0], q[1], q[2]), ocl.Point(r[0], r[1], r[2])) s.addTriangle(t) if obj.Algorithm == 'OCL Dropcutter': output = self._dropcutter(obj, s, bb) elif obj.Algorithm == 'OCL Waterline': output = self._waterline(obj, s, bb) path = Path.Path(output) obj.Path = path
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) # obj.ToolController = PathUtils.getToolControllers(obj) # toolLoad = PathUtils.getToolLoad(obj, obj.ToolController) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" if obj.Side != "On": output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" if obj.Base: # hfaces = [] # vfaces = [] wires = [] for b in obj.Base: edgelist = [] for sub in b[1]: edgelist.append(getattr(b[0].Shape, sub)) wires.extend(findWires(edgelist)) for wire in wires: edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" if obj.Side != "On": output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" if obj.Base: holes = [] faces = [] for b in obj.Base: for sub in b[1]: shape = getattr(b[0].Shape, sub) if isinstance (shape, Part.Face): faces.append(shape) if numpy.isclose(abs(shape.normalAt(0, 0).z), 1): # horizontal face holes += shape.Wires[1:] else: print ("found a base object which is not a face. Can't continue.") return profileshape = Part.makeCompound(faces) profilewire = TechDraw.findShapeOutline(profileshape, 1, Vector(0,0,1)) if obj.processHoles: for wire in holes: edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist, True) if obj.processPerimeter: edgelist = profilewire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist, False) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) # obj.ToolController = PathUtils.getToolControllers(obj) # toolLoad = PathUtils.getToolLoad(obj, obj.ToolController) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" if obj.Side != "On": output += "(Compensated Tool Path. Diameter: " + str( self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" if obj.Base: # hfaces = [] # vfaces = [] wires = [] for b in obj.Base: edgelist = [] for sub in b[1]: edgelist.append(getattr(b[0].Shape, sub)) wires.extend(findWires(edgelist)) for wire in wires: edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: for b in obj.Base: for sub in b[1]: print "object base: " + str(b) import Part import PathScripts.PathKurveUtils if "Face" in sub: print "inside" shape = getattr(b[0].Shape, sub) wire = shape.OuterWire edges = wire.Edges else: print "in else" edges = [getattr(b[0].Shape, sub) for sub in b[1]] print "myedges: " + str(edges) wire = Part.Wire(edges) shape = None # output = "" if obj.Algorithm == "OCC Native": if shape is None: shape = wire output += self.buildpathocc(obj, shape) else: try: import area except: FreeCAD.Console.PrintError(translate("PathKurve", "libarea needs to be installed for this command to work.\n")) return a = area.Area() if shape is None: c = PathScripts.PathKurveUtils.makeAreaCurve(wire.Edges, 'CW') a.append(c) else: for w in shape.Wires: c = PathScripts.PathKurveUtils.makeAreaCurve(w.Edges, 'CW') # if w.isSame(shape.OuterWire): # print "outerwire" # if c.IsClockwise(): # c.Reverse() # print "reverse outterwire" # else: # print "inner wire" # if not c.IsClockwise(): # c.Reverse() # print "reverse inner" a.append(c) ######## # This puts out some interesting information from libarea print a.text() ######## a.Reorder() output += self.buildpathlibarea(obj, a) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): if not obj.Active: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False return #Tool may have changed. Refresh data toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horiRrapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name #Build preliminary comments output = "" output += "(" + obj.Label + ")" if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription #Facing is done either against base objects if obj.Base: faces = [] for b in obj.Base: for sub in b[1]: shape = getattr(b[0].Shape, sub) if isinstance (shape, Part.Face): faces.append(shape) else: print ('falling out') return planeshape = Part.makeCompound(faces) #If no base object, do planing of top surface of entire model else: parentJob = PathUtils.findParentJob(obj) if parentJob is None: return baseobject = parentJob.Base if baseobject is None: return planeshape = baseobject.Shape #if user wants the boundbox, calculate that if obj.BoundaryShape == 'Boundbox': bb = planeshape.BoundBox bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, Vector(bb.XMin, bb.YMin, bb.ZMin), Vector(0,0,1)) contourwire = TechDraw.findShapeOutline(bbperim, 1, Vector(0,0,1)) else: contourwire = TechDraw.findShapeOutline(planeshape, 1, Vector(0,0,1)) edgelist = contourwire.Edges edgelist = Part.__sortEdges__(edgelist) #use libarea to build the pattern a = area.Area() c = PathScripts.PathKurveUtils.makeAreaCurve(edgelist, 'CW') a.append(c) a.Reorder() output += self.buildpathlibarea(obj, a) path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True
def execute(self, obj): output = "" if obj.Comment != "": output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription locations = [] output = "(Begin Drilling)\n" if obj.Base: for loc in obj.Base: for sub in loc[1]: if "Face" in sub or "Edge" in sub: s = getattr(loc[0].Shape, sub) else: s = loc[0].Shape if s.ShapeType in ['Wire', 'Edge']: X = s.Edges[0].Curve.Center.x Y = s.Edges[0].Curve.Center.y Z = s.Edges[0].Curve.Center.z elif s.ShapeType in ['Vertex']: X = s.Point.x Y = s.Point.y Z = s.Point.z elif s.ShapeType in ['Face']: #if abs(s.normalAt(0, 0).z) == 1: # horizontal face X = s.CenterOfMass.x Y = s.CenterOfMass.y Z = s.CenterOfMass.z locations.append(FreeCAD.Vector(X, Y, Z)) output += "G90 G98\n" # rapid to clearance height output += "G0 Z" + str(obj.ClearanceHeight.Value) # rapid to first hole location, with spindle still retracted: p0 = locations[0] output += "G0 X" + fmt(p0.x) + " Y" + fmt(p0.y) + "\n" # move tool to clearance plane output += "G0 Z" + fmt(obj.ClearanceHeight.Value) + "\n" if obj.PeckDepth.Value > 0: cmd = "G83" qword = " Q" + fmt(obj.PeckDepth.Value) else: cmd = "G81" qword = "" for p in locations: output += cmd + \ " X" + fmt(p.x) + \ " Y" + fmt(p.y) + \ " Z" + fmt(obj.FinalDepth.Value) + qword + \ " R" + str(obj.RetractHeight.Value) + \ " F" + str(self.vertFeed) + "\n" \ output += "G80\n" # path = Path.Path(output) # obj.Path = path if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): if obj.Base: # tie the toolnumber to the PathLoadTool object ToolNumber if len(obj.InList ) > 0: #check to see if obj is in the Project group yet project = obj.InList[0] tl = int(PathUtils.changeTool(obj, project)) obj.ToolNumber = tl tool = PathUtils.getTool(obj, obj.ToolNumber) if tool: radius = tool.Diameter / 2 else: # temporary value, to be taken from the properties later on radius = 0.001 if obj.Base[0].Shape.ShapeType == "Wire": #a pure wire was picked wire = obj.Base[0].Shape else: #we are dealing with a face and it's edges or just a face if obj.Edge1: e1 = FreeCAD.ActiveDocument.getObject( obj.Base[0].Name).Shape.Edges[ eval(obj.Edge1[1][0].lstrip('Edge')) - 1] if e1.BoundBox.ZMax <> e1.BoundBox.ZMin: FreeCAD.Console.PrintError( 'vertical edges not valid yet\n') return if obj.Base[0].Shape.ShapeType == 'Wire': wire = obj.Base[0].Shape if obj.Base[0].Shape.ShapeType == 'Solid' or obj.Base[ 0].Shape.ShapeType == 'Compound': shape = obj.Base[0].Shape for fw in shape.Wires: if (fw.BoundBox.ZMax == e1.BoundBox.ZMax) and ( fw.BoundBox.ZMin == e1.BoundBox.ZMin): for e in fw.Edges: if e.isSame(e1): #FreeCAD.Console.PrintMessage('found the same objects\n') wire = fw elif obj.Face1: # we are only dealing with a face or faces f1 = FreeCAD.ActiveDocument.getObject( obj.Base[0].Name).Shape.Faces[ eval(obj.Face1[1][0].lstrip('Face')) - 1] # make the side Left and direction CW for normal cnc milling obj.Direction = 'CW' obj.Side = "Left" # we only consider the outer wire if this is a single Face wire = f1.OuterWire if obj.Direction == 'CCW': clockwise = False else: clockwise = True output = "" output += '(' + str(obj.Comment) + ')\n' FirstEdge = None if obj.Edge1: ename = obj.Edge1[1][0] edgeNumber = int(ename[4:]) - 1 FirstEdge = obj.Base[0].Shape.Edges[edgeNumber] ZMax = obj.Base[0].Shape.BoundBox.ZMax ZCurrent = obj.ClearanceHeight.Value if obj.UseStartDepth: output += PathUtils.MakePath( wire, obj.Side, radius, clockwise, obj.ClearanceHeight.Value, obj.StepDown.Value, obj.StartDepth.Value, obj.FinalDepth.Value, FirstEdge, obj.PathClosed, obj.SegLen.Value, obj.VertFeed.Value, obj.HorizFeed.Value) else: output += PathUtils.MakePath( wire, obj.Side, radius, clockwise, obj.ClearanceHeight.Value, obj.StepDown.Value, ZMax, obj.FinalDepth.Value, FirstEdge, obj.PathClosed, obj.SegLen.Value, obj.VertFeed.Value, obj.HorizFeed.Value) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def __init__(self, obj): from Units import Quantity self.obj = obj ui = FreeCADGui.UiLoader() layout = QtGui.QGridLayout() headerStyle = "QLabel { font-weight: bold; font-size: large; }" grayed_out = "background-color: #d0d0d0;" self.previous_value = {} def addWidget(widget): row = layout.rowCount() layout.addWidget(widget, row, 0, 1, 2) def addWidgets(widget1, widget2): row = layout.rowCount() layout.addWidget(widget1, row, 0) layout.addWidget(widget2, row, 1) def heading(label): heading = QtGui.QLabel(label) heading.setStyleSheet(headerStyle) addWidget(heading) def addQuantity(property, labelstring, activator=None, max=None): self.previous_value[property] = getattr(self.obj, property) widget = ui.createWidget("Gui::InputField") if activator: self.previous_value[activator] = getattr(self.obj, activator) currently_active = getattr(self.obj, activator) label = QtGui.QCheckBox(labelstring) def change(state): setattr(self.obj, activator, label.isChecked()) if label.isChecked(): widget.setStyleSheet("") else: widget.setStyleSheet(grayed_out) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() label.stateChanged.connect(change) label.setChecked(currently_active) if not currently_active: widget.setStyleSheet(grayed_out) label.setToolTip( self.obj.getDocumentationOfProperty(activator)) else: label = QtGui.QLabel(labelstring) label.setToolTip(self.obj.getDocumentationOfProperty(property)) widget.setText(str(getattr(self.obj, property))) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) if max: # cannot use widget.setMaximum() as apparently ui.createWidget() # returns the object up-casted to QWidget. widget.setProperty("maximum", max) def change(quantity): setattr(self.obj, property, quantity) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() QtCore.QObject.connect( widget, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), change) addWidgets(label, widget) return label, widget def addCheckBox(property, label): self.previous_value[property] = getattr(self.obj, property) widget = QtGui.QCheckBox(label) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) def change(state): setattr(self.obj, property, widget.isChecked()) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.stateChanged.connect(change) widget.setChecked(getattr(self.obj, property)) addWidget(widget) def addEnumeration(property, label, options): self.previous_value[property] = getattr(self.obj, property) label = QtGui.QLabel(label) label.setToolTip(self.obj.getDocumentationOfProperty(property)) widget = QtGui.QComboBox() widget.setToolTip(self.obj.getDocumentationOfProperty(property)) for option_label, option_value in options: widget.addItem(option_label) def change(index): setattr(self.obj, property, options[index][1]) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.currentIndexChanged.connect(change) addWidgets(label, widget) self.featureTree = QtGui.QTreeWidget() self.featureTree.setMinimumHeight(200) self.featureTree.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) #self.featureTree.setDragDropMode(QtGui.QAbstractItemView.DragDrop) #self.featureTree.setDefaultDropAction(QtCore.Qt.MoveAction) self.fillFeatureTree() sm = self.featureTree.selectionModel() sm.selectionChanged.connect(self.selectFeatures) addWidget(self.featureTree) self.featureTree.expandAll() self.addButton = QtGui.QPushButton("Add holes") self.addButton.clicked.connect(self.addCylinders) self.delButton = QtGui.QPushButton("Delete") self.delButton.clicked.connect(self.delCylinders) addWidgets(self.addButton, self.delButton) heading("Drill parameters") addCheckBox("Active", "Operation is active") tool = PathUtils.getTool(self.obj, self.obj.ToolNumber) if not tool: drmax = None else: drmax = tool.Diameter addQuantity("DeltaR", "Step in Radius", max=drmax) addQuantity("StepDown", "Step in Z") addEnumeration("Direction", "Cut direction", [("Clockwise", "CW"), ("Counter-Clockwise", "CCW")]) addEnumeration("StartSide", "Start Side", [("Start from inside", "inside"), ("Start from outside", "outside")]) heading("Cutting Depths") addQuantity("Clearance", "Clearance Distance") addQuantity("StartDepth", "Absolute start height", "UseStartDepth") fdcheckbox, fdinput = addQuantity("FinalDepth", "Absolute final height", "UseFinalDepth") tdlabel, tdinput = addQuantity("ThroughDepth", "Extra drill depth\nfor open holes") # make ThroughDepth and FinalDepth mutually exclusive def fd_change(state): if fdcheckbox.isChecked(): tdinput.setStyleSheet(grayed_out) else: tdinput.setStyleSheet("") fdcheckbox.stateChanged.connect(fd_change) def td_change(quantity): fdcheckbox.setChecked(False) QtCore.QObject.connect( tdinput, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), td_change) if obj.UseFinalDepth: tdinput.setStyleSheet(grayed_out) # add widget = QtGui.QWidget() widget.setLayout(layout) self.form = widget
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" if not obj.UseComp: output += "(Compensated Tool Path. Diameter: " + str( self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" parentJob = PathUtils.findParentJob(obj) if parentJob is None: return baseobject = parentJob.Base if baseobject is None: return print "base object: " + baseobject.Name contourwire = PathUtils.silhouette(baseobject) edgelist = contourwire.Edges edgelist = Part.__sortEdges__(edgelist) try: output += self._buildPathLibarea(obj, edgelist) except: FreeCAD.Console.PrintError( "Something unexpected happened. Unable to generate a contour path. Check project and tool config." ) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): if not obj.Active: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False return #Tool may have changed. Refresh data toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horiRrapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name #Build preliminary comments output = "" output += "(" + obj.Label + ")" if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription #Facing is done either against base objects if obj.Base: faces = [] for b in obj.Base: for sub in b[1]: shape = getattr(b[0].Shape, sub) if isinstance(shape, Part.Face): faces.append(shape) else: print('falling out') return planeshape = Part.makeCompound(faces) #If no base object, do planing of top surface of entire model else: parentJob = PathUtils.findParentJob(obj) if parentJob is None: return baseobject = parentJob.Base if baseobject is None: return planeshape = baseobject.Shape #if user wants the boundbox, calculate that if obj.BoundaryShape == 'Boundbox': bb = planeshape.BoundBox bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, Vector(bb.XMin, bb.YMin, bb.ZMin), Vector(0, 0, 1)) contourwire = TechDraw.findShapeOutline(bbperim, 1, Vector(0, 0, 1)) else: contourwire = TechDraw.findShapeOutline(planeshape, 1, Vector(0, 0, 1)) edgelist = contourwire.Edges edgelist = Part.__sortEdges__(edgelist) #use libarea to build the pattern a = area.Area() c = PathScripts.PathKurveUtils.makeAreaCurve(edgelist, 'CW') a.append(c) a.Reorder() output += self.buildpathlibarea(obj, a) path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True
def execute(self,obj): if obj.Base: # tie the toolnumber to the PathLoadTool object ToolNumber if len(obj.InList)>0: #check to see if obj is in the Project group yet project = obj.InList[0] tl = int(PathUtils.changeTool(obj,project)) obj.ToolNumber= tl tool = PathUtils.getTool(obj,obj.ToolNumber) if tool: radius = tool.Diameter/2 else: # temporary value, to be taken from the properties later on radius = 0.001 if obj.Base[0].Shape.ShapeType == "Wire": #a pure wire was picked wire = obj.Base[0].Shape else: #we are dealing with a face and it's edges or just a face if obj.Edge1: e1 = FreeCAD.ActiveDocument.getObject(obj.Base[0].Name).Shape.Edges[eval(obj.Edge1[1][0].lstrip('Edge'))-1] if e1.BoundBox.ZMax <> e1.BoundBox.ZMin: FreeCAD.Console.PrintError('vertical edges not valid yet\n') return if obj.Base[0].Shape.ShapeType =='Wire': wire = obj.Base[0].Shape if obj.Base[0].Shape.ShapeType =='Solid' or obj.Base[0].Shape.ShapeType =='Compound': shape = obj.Base[0].Shape for fw in shape.Wires: if (fw.BoundBox.ZMax == e1.BoundBox.ZMax) and (fw.BoundBox.ZMin == e1.BoundBox.ZMin): for e in fw.Edges: if e.isSame(e1): #FreeCAD.Console.PrintMessage('found the same objects\n') wire = fw elif obj.Face1: # we are only dealing with a face or faces f1 = FreeCAD.ActiveDocument.getObject(obj.Base[0].Name).Shape.Faces[eval(obj.Face1[1][0].lstrip('Face'))-1] # make the side Left and direction CW for normal cnc milling obj.Direction = 'CW' obj.Side = "Left" # we only consider the outer wire if this is a single Face wire = f1.OuterWire if obj.Direction == 'CCW': clockwise=False else: clockwise=True output ="" output += '('+ str(obj.Comment)+')\n' FirstEdge= None if obj.Edge1: ename = obj.Edge1[1][0] edgeNumber = int(ename[4:])-1 FirstEdge = obj.Base[0].Shape.Edges[edgeNumber] ZMax = obj.Base[0].Shape.BoundBox.ZMax ZCurrent = obj.ClearanceHeight.Value if obj.UseStartDepth: output += PathUtils.MakePath(wire,obj.Side,radius,clockwise,obj.ClearanceHeight.Value,obj.StepDown.Value,obj.StartDepth.Value, obj.FinalDepth.Value,FirstEdge,obj.PathClosed,obj.SegLen.Value,obj.VertFeed.Value,obj.HorizFeed.Value) else: output += PathUtils.MakePath(wire,obj.Side,radius,clockwise,obj.ClearanceHeight.Value,obj.StepDown.Value,ZMax, obj.FinalDepth.Value,FirstEdge,obj.PathClosed,obj.SegLen.Value,obj.VertFeed.Value,obj.HorizFeed.Value) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: hfaces = [] vfaces = [] wires = [] for b in obj.Base: for sub in b[1]: # we only consider the outer wire if this is a Face # Horizontal and vertical faces are handled differently shape = getattr(b[0].Shape, sub) if numpy.isclose(shape.normalAt(0, 0).z, 1): # horizontal face hfaces.append(shape) elif numpy.isclose(shape.normalAt(0, 0).z, 0): # vertical face vfaces.append(shape) else: FreeCAD.Console.PrintError(translate("Path", "Face doesn't appear to be parallel or perpendicular to the XY plane. No path will be generated for: \n")) FreeCAD.Console.PrintError(b[0].Name + "." + sub + "\n") for h in hfaces: wires.append(h.OuterWire) tempshell = Part.makeShell(vfaces) slices = tempshell.slice(FreeCAD.Base.Vector(0, 0, 1), tempshell.CenterOfMass.z ) wires = wires + slices for wire in wires: if obj.Algorithm == "OCC Native": output += self._buildPathOCC(obj, wire) else: try: import area except: FreeCAD.Console.PrintError(translate("Path", "libarea needs to be installed for this command to work.\n")) return edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: locations = [] for loc in obj.Base: if "Face" in loc[1] or "Edge" in loc[1]: s = getattr(loc[0].Shape, loc[1]) else: s = loc[0].Shape if s.ShapeType in ['Wire', 'Edge']: X = s.Edges[0].Curve.Center.x Y = s.Edges[0].Curve.Center.y Z = s.Edges[0].Curve.Center.z elif s.ShapeType in ['Vertex']: X = s.Point.x Y = s.Point.y Z = s.Point.z elif s.ShapeType in ['Face']: #if abs(s.normalAt(0, 0).z) == 1: # horizontal face X = s.CenterOfMass.x Y = s.CenterOfMass.y Z = s.CenterOfMass.z locations.append(FreeCAD.Vector(X, Y, Z)) output = "G90 G98\n" # rapid to clearance height output += "G0 Z" + str(obj.ClearanceHeight.Value) # rapid to first hole location, with spindle still retracted: p0 = locations[0] output += "G0 X" + str(p0.x) + " Y" + str(p0.y) + "\n" # move tool to clearance plane output += "G0 Z" + str(obj.ClearanceHeight.Value) + "\n" if obj.PeckDepth.Value > 0: cmd = "G83" qword = " Q" + str(obj.PeckDepth.Value) else: cmd = "G81" qword = "" for p in locations: output += cmd + \ " X" + str(p.x) + \ " Y" + str(p.y) + \ " Z" + str(obj.FinalDepth.Value) + qword + \ " R" + str(obj.RetractHeight.Value) + \ " F" + str(self.vertFeed) + "\n" \ output += "G80\n" path = Path.Path(output) obj.Path = path
def execute(self, obj): import Part # math #DraftGeomUtils output = "" toolLoad = PathUtils.getLastToolLoad(obj) # obj.ToolController = PathUtils.getToolControllers(obj) # toolLoad = PathUtils.getToolLoad(obj, obj.ToolController) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(" + obj.Label + ")" if obj.Side != "On": output += "(Compensated Tool Path. Diameter: " + str( self.radius * 2) + ")" else: output += "(Uncompensated Tool Path)" if obj.Base: hfaces = [] vfaces = [] wires = [] holes = [] for b in obj.Base: for sub in b[1]: # we only consider the outer wire if this is a Face # Horizontal and vertical faces are handled differently shape = getattr(b[0].Shape, sub) if numpy.isclose(abs(shape.normalAt(0, 0).z), 1): # horizontal face hfaces.append(shape) elif numpy.isclose(shape.normalAt(0, 0).z, 0): # vertical face vfaces.append(shape) else: FreeCAD.Console.PrintError( translate( "Path", "Face doesn't appear to be parallel or perpendicular to the XY plane. No path will be generated for: \n" )) FreeCAD.Console.PrintError(b[0].Name + "." + sub + "\n") if obj.processHoles: for h in hfaces: holes += h.Wires[1:] for h in hfaces: wires.append(h.OuterWire) tempshell = Part.makeShell(vfaces) slices = tempshell.slice(FreeCAD.Base.Vector(0, 0, 1), tempshell.CenterOfMass.z) wires = wires + slices for wire in holes: if obj.Algorithm == "OCC Native": output += self._buildPathOCC(obj, wire) else: try: import area except: FreeCAD.Console.PrintError( translate( "Path", "libarea needs to be installed for this command to work.\n" )) return edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist, True) for wire in wires: if obj.Algorithm == "OCC Native": output += self._buildPathOCC(obj, wire) else: try: import area except: FreeCAD.Console.PrintError( translate( "Path", "libarea needs to be installed for this command to work.\n" )) return edgelist = wire.Edges edgelist = Part.__sortEdges__(edgelist) output += self._buildPathLibarea(obj, edgelist, False) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter / 2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " (" + obj.ToolDescription + ")" else: obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" if obj.Base: for b in obj.Base: print "object base: " + str(b) import Part import PathScripts.PathKurveUtils if "Face" in b[1]: print "inside" shape = getattr(b[0].Shape, b[1]) wire = shape.OuterWire edges = wire.Edges else: print "in else" edges = [getattr(b[0].Shape, sub) for sub in b[1]] print "myedges: " + str(edges) wire = Part.Wire(edges) shape = None # output = "" if obj.Algorithm == "OCC Native": if shape is None: shape = wire output += self.buildpathocc(obj, shape) else: try: import area except: FreeCAD.Console.PrintError( translate( "PathKurve", "libarea needs to be installed for this command to work.\n" )) return a = area.Area() if shape is None: c = PathScripts.PathKurveUtils.makeAreaCurve( wire.Edges, 'CW') a.append(c) else: for w in shape.Wires: c = PathScripts.PathKurveUtils.makeAreaCurve( w.Edges, 'CW') # if w.isSame(shape.OuterWire): # print "outerwire" # if c.IsClockwise(): # c.Reverse() # print "reverse outterwire" # else: # print "inner wire" # if not c.IsClockwise(): # c.Reverse() # print "reverse inner" a.append(c) ######## # This puts out some interesting information from libarea print a.text() ######## a.Reorder() output += self.buildpathlibarea(obj, a) if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False
def execute(self, obj): output = "" if obj.Comment != "": output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 self.horizFeed = 100 self.vertRapid = 100 self.horizRapid = 100 self.radius = 0.25 obj.ToolNumber = 0 obj.ToolDescription = "UNDEFINED" else: self.vertFeed = toolLoad.VertFeed.Value self.horizFeed = toolLoad.HorizFeed.Value self.vertRapid = toolLoad.VertRapid.Value self.horizRapid = toolLoad.HorizRapid.Value tool = PathUtils.getTool(obj, toolLoad.ToolNumber) if tool.Diameter == 0: self.radius = 0.25 else: self.radius = tool.Diameter/2 obj.ToolNumber = toolLoad.ToolNumber obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": obj.Label = obj.Name + " :" + obj.ToolDescription else: obj.Label = obj.UserLabel + " :" + obj.ToolDescription locations = [] output = "(Begin Drilling)\n" if obj.Base: for loc in obj.Base: #print loc for sub in loc[1]: #locations.append(self._findDrillingVector(loc)) if "Face" in sub or "Edge" in sub: s = getattr(loc[0].Shape, sub) else: s = loc[0].Shape if s.ShapeType in ['Wire', 'Edge']: X = s.Edges[0].Curve.Center.x Y = s.Edges[0].Curve.Center.y Z = s.Edges[0].Curve.Center.z elif s.ShapeType in ['Vertex']: X = s.Point.x Y = s.Point.y Z = s.Point.z elif s.ShapeType in ['Face']: #if abs(s.normalAt(0, 0).z) == 1: # horizontal face X = s.CenterOfMass.x Y = s.CenterOfMass.y Z = s.CenterOfMass.z locations.append(FreeCAD.Vector(X, Y, Z)) output += "G90 G98\n" # rapid to clearance height output += "G0 Z" + str(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n" # rapid to first hole location, with spindle still retracted: p0 = locations[0] output += "G0 X" + fmt(p0.x) + " Y" + fmt(p0.y) + "F " + PathUtils.fmt(self.horizRapid) + "\n" # move tool to clearance plane output += "G0 Z" + fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n" pword = "" qword = "" if obj.PeckDepth.Value > 0: cmd = "G83" qword = " Q" + fmt(obj.PeckDepth.Value) elif obj.DwellTime > 0: cmd = "G82" pword = " P" + fmt(obj.DwellTime) else: cmd = "G81" for p in locations: output += cmd + \ " X" + fmt(p.x) + \ " Y" + fmt(p.y) + \ " Z" + fmt(obj.FinalDepth.Value) + qword + pword + \ " R" + str(obj.RetractHeight.Value) + \ " F" + str(self.vertFeed) + "\n" \ output += "G80\n" # path = Path.Path(output) # obj.Path = path if obj.Active: path = Path.Path(output) obj.Path = path obj.ViewObject.Visibility = True else: path = Path.Path("(inactive operation)") obj.Path = path obj.ViewObject.Visibility = False