def execute(self,obj): output = "G90 G98\n" # rapid to first hole location, with spindle still retracted: p0 = obj.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 obj.locations: output += cmd + " X" + str(p.x) + " Y" + str(p.y) + " Z" + str(obj.FinalDepth.Value) + qword + " R" + str(obj.RetractHeight.Value) + " F" + str(obj.VertFeed.Value) + "\n" output += "G80\n" print output path = Path.Path(output) obj.Path = path # 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
def execute(self, obj): output = "G90 G98\n" # rapid to first hole location, with spindle still retracted: p0 = obj.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 obj.locations: output += cmd + " X" + str(p.x) + " Y" + str(p.y) + " Z" + str( obj.FinalDepth.Value) + qword + " R" + str( obj.RetractHeight.Value) + " F" + str( obj.VertFeed.Value) + "\n" output += "G80\n" print output path = Path.Path(output) obj.Path = path # 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
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): command = 'G43H'+str(obj.HeightNumber)+'G0Z'+str(obj.Height.Value) obj.Path = Path.Path(command) obj.Label = "Height"+str(obj.HeightNumber) if obj.Active: obj.Path = Path.Path(command) obj.ViewObject.Visibility = True else: obj.Path = Path.Path("(inactive operation)") obj.ViewObject.Visibility = False # tie the HeightNumber 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.HeightNumber= tl
def Activated(self): import Path import Part from PathScripts import PathUtils, PathDrilling, PathProject prjexists = False selection = FreeCADGui.Selection.getSelectionEx() if not selection: return # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction( translate("Path_Drilling", "Create Drilling")) FreeCADGui.addModule("PathScripts.PathDrilling") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Drilling") PathDrilling.ObjectDrilling(obj) myList = obj.locations for sub in selection: for point in sub.SubObjects: if isinstance(point, Part.Vertex): myList.append(FreeCAD.Vector(point.X, point.Y, point.Z)) if isinstance(point, Part.Edge): if isinstance(point.Curve, Part.Circle): center = point.Curve.Center myList.append( FreeCAD.Vector(center.x, center.y, center.z)) obj.locations = myList PathDrilling._ViewProviderDrill(obj.ViewObject) # obj.ViewObject.Proxy = 0 obj.Active = True project = PathUtils.addToProject(obj) tl = PathUtils.changeTool(obj, project) if tl: obj.ToolNumber = tl FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute()
def Activated(self): import Path import Part from PathScripts import PathUtils,PathDrilling,PathProject prjexists = False selection = FreeCADGui.Selection.getSelectionEx() if not selection: return # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction(translate("PathDrilling","Create Drilling")) FreeCADGui.addModule("PathScripts.PathDrilling") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Drilling") PathDrilling.ObjectDrilling(obj) myList = obj.locations for sub in selection: for point in sub.SubObjects: if isinstance(point,Part.Vertex): myList.append(FreeCAD.Vector(point.X, point.Y, point.Z)) if isinstance(point,Part.Edge): if isinstance(point.Curve,Part.Circle): center = point.Curve.Center myList.append(FreeCAD.Vector(center.x,center.y,center.z)) obj.locations = myList PathDrilling._ViewProviderDrill(obj.ViewObject) # obj.ViewObject.Proxy = 0 obj.Active = True project = PathUtils.addToProject(obj) tl = PathUtils.changeTool(obj,project) if tl: obj.ToolNumber = tl FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute()
def Activated(self): import Path from PathScripts import PathUtils, PathProfile, PathProject prjexists = False selection = PathSelection.multiSelect() if not selection: return # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction( translate("PathProfile", "Create Profile")) FreeCADGui.addModule("PathScripts.PathProfile") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "Profile") PathProfile.ObjectProfile(obj) PathProfile.ViewProviderProfile(obj.ViewObject) obj.Base = (FreeCAD.ActiveDocument.getObject(selection['objname'])) if selection['facenames']: #FreeCAD.Console.PrintMessage('There are edges selected\n') obj.Face1 = (FreeCAD.ActiveDocument.getObject( selection['objname']), selection['facenames'][0]) if len(selection['facenames']) > 1: obj.Face2 = (FreeCAD.ActiveDocument.getObject( selection['objname']), selection['facenames'][-1]) if selection['edgenames']: #FreeCAD.Console.PrintMessage('There are edges selected\n') obj.Edge1 = (FreeCAD.ActiveDocument.getObject( selection['objname']), (selection['edgenames'][0])) if len(selection['edgenames']) > 1: obj.Edge2 = (FreeCAD.ActiveDocument.getObject( selection['objname']), (selection['edgenames'][-1])) if selection['pointlist']: FreeCADGui.doCommand('from FreeCAD import Vector') stptX, stptY, stptZ = selection['pointlist'][0].X, selection[ 'pointlist'][0].Y, selection['pointlist'][0].Z obj.StartPoint = Vector((stptX), (stptY), (stptZ)) if len( selection['pointlist'] ) > 1: # we have more than one point so we have an end point endptX, endptY, endptZ = selection['pointlist'][ -1].X, selection['pointlist'][-1].Y, selection[ 'pointlist'][-1].Z obj.EndPoint = Vector(endptX, endptY, endptZ) if selection['pathwire'].isClosed(): obj.PathClosed = True if selection['clockwise']: obj.Side = "Left" obj.Direction = "CW" elif selection['clockwise'] == False: obj.Side = "Right" obj.Direction = "CCW" else: obj.Side = "On" obj.Direction = "CCW" obj.PathClosed = False ZMax = obj.Base[0].Shape.BoundBox.ZMax ZMin = obj.Base[0].Shape.BoundBox.ZMin obj.StepDown.Value = 1.0 obj.StartDepth.Value = ZMax - obj.StepDown.Value obj.FinalDepth.Value = ZMin - 1.0 obj.ClearanceHeight.Value = ZMax + 5.0 obj.SegLen.Value = 0.5 obj.Active = True obj.ViewObject.ShowFirstRapid = False project = PathUtils.addToProject(obj) tl = PathUtils.changeTool(obj, project) if tl: obj.ToolNumber = tl FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute()
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 Activated(self): import Path from PathScripts import PathUtils,PathProfile,PathProject prjexists = False selection = PathSelection.multiSelect() if not selection: return # if everything is ok, execute and register the transaction in the undo/redo stack FreeCAD.ActiveDocument.openTransaction(translate("Path_Profile","Create Profile")) FreeCADGui.addModule("PathScripts.PathProfile") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Profile") PathProfile.ObjectProfile(obj) PathProfile.ViewProviderProfile(obj.ViewObject) obj.Base = (FreeCAD.ActiveDocument.getObject(selection['objname'])) if selection['facenames']: #FreeCAD.Console.PrintMessage('There are edges selected\n') obj.Face1 = (FreeCAD.ActiveDocument.getObject(selection['objname']),selection['facenames'][0]) if len(selection['facenames'])>1: obj.Face2 = (FreeCAD.ActiveDocument.getObject(selection['objname']),selection['facenames'][-1]) if selection['edgenames']: #FreeCAD.Console.PrintMessage('There are edges selected\n') obj.Edge1 =(FreeCAD.ActiveDocument.getObject(selection['objname']),(selection['edgenames'][0])) if len(selection['edgenames'])>1: obj.Edge2 =(FreeCAD.ActiveDocument.getObject(selection['objname']),(selection['edgenames'][-1])) if selection['pointlist']: FreeCADGui.doCommand('from FreeCAD import Vector') stptX, stptY, stptZ = selection['pointlist'][0].X, selection['pointlist'][0].Y, selection['pointlist'][0].Z obj.StartPoint = Vector((stptX),(stptY),(stptZ)) if len(selection['pointlist'])>1: # we have more than one point so we have an end point endptX, endptY, endptZ = selection['pointlist'][-1].X, selection['pointlist'][-1].Y, selection['pointlist'][-1].Z obj.EndPoint = Vector(endptX,endptY,endptZ) if selection['pathwire'].isClosed(): obj.PathClosed = True if selection['clockwise']: obj.Side = "Left" obj.Direction = "CW" elif selection['clockwise'] == False: obj.Side = "Right" obj.Direction = "CCW" else: obj.Side = "On" obj.Direction = "CCW" obj.PathClosed = False ZMax = obj.Base[0].Shape.BoundBox.ZMax ZMin = obj.Base[0].Shape.BoundBox.ZMin obj.StepDown.Value = 1.0 obj.StartDepth.Value = ZMax- obj.StepDown.Value obj.FinalDepth.Value = ZMin-1.0 obj.ClearanceHeight.Value = ZMax + 5.0 obj.SegLen.Value = 0.5 obj.Active = True obj.ViewObject.ShowFirstRapid = False project = PathUtils.addToProject(obj) tl = PathUtils.changeTool(obj,project) if tl: obj.ToolNumber = tl FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute()
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