My python script is now completed. It is a 2D (from dxf) script to generate a laser chamfer by varying Spindle , Feed and Number of contours
Example :
Profile 1 : F2000S30 offset 0.1
Profile 2 : F1900S35 offset 0.2
Profile 3 : F1800S40 offset 0.3 ...
A final operation makes a pocket with the last Feed and Spindle values. From a 2D sideview , the profile around a shape is a chamfer on both sides.
And here is the (amateurish) Code :
#Imports and definitions
from CamBam.CAM import *
from CamBam.UI import CamBamUI
from CamBam.Values import *
newdoc = CamBamUI.MainUI.ActiveView.CADFile
newdoc.MachiningOptions.PostProcessor = "Laserbot_2D" #My Postprocessor is deleting all the Z values and replacing M3 vith M4
Clear = 0.0
i = 0
#Define the Range and number of profiles
layer=0
lines=20
largeur=10 #thats width in french
Spin = 70
SpinMax=100
Feed = 4000
FeedMin=3000
#Calculation of increments
Spinplus = float(SpinMax-Spin)/float(lines)
Feedinc =(Feed-FeedMin)/(lines-1)
width=largeur-(lines/10)
name= "ContourMagique"
#Create the 2 parts
part= doc.CreatePart("Contours")
part2 = doc.CreatePart("Finish")
#Iterate the contours while varying SpindleSpeed Feed and Offset
while i <lines:
profile=MOPProfile(newdoc,newdoc.Layers[layer].Entities.ToArray())
profile.ToolDiameter = CBValue[float](0.1)
profile.StepOver=CBValue[float](1)
profile.Style="cutout"
profile.Name= name+str(i)
profile.SpindleSpeed = CBValue[int](Spinint)
profile.CutFeedrate = CBValue[float](Feed)
profile.RoughingClearance = CBValue[float](Clear)
profile.GetCAMStyle()
profile.InsideOutside = CBValue[InsideOutsideOptions](InsideOutsideOptions.Outside)
profile.LeadInMove = CBValue[LeadMoveInfo](None)
part.MachineOps.Add(profile)
Spin += Spinplus
Spinint=int(Spin)
Clear+=0.1
Feed-=Feedinc
i+=1
#Create the Finishing pocket
profile=MOPProfile(newdoc,newdoc.Layers[0].Entities.ToArray())
profile.Name="Finish"
profile.SpindleSpeed = CBValue[int](Spinint)
profile.CutFeedrate = CBValue[float](Feed)
profile.RoughingClearance = CBValue[float](Clear)
profile.ToolDiameter = CBValue[float](0.1)
profile.CutWidth = CBValue[float](width)
profile.StepOver=CBValue[float](1)
part2.MachineOps.Add(profile)
The main issue of the obtained Mops is there is absolutely no cut ordering . I guess making a new operation plugin would be necessary to do all the operations profile by profile... but that's another topic
Hope someone will find this usefull!