Shouldn't be too terribly difficult...here's some code grabbed from another project:
Code: Select all Public Const DefaultRapidWord As String = "G00"
Public Const DefaultFeedWord As String = "G01"
Public Const DefaultSpindleWord As String = "M03"
Public Const DefaultStartCodes As String = "%" & vbCrLf & _
":1111(auto-generated)" & vbCrLf & _
"G00G17G20G28G40G80G91Z0" & vbCrLf & _
"G90" & vbCrLf & _
"G52X0Y0Z0M5" & vbCrLf & _
"G08P1" & vbCrLf
Public Const DefaultToolChangeCodes As String = "(CoreBoxBit)" & vbCrLf & _
"G28G91Z0M05" & vbCrLf & _
"G90T2001M06" & vbCrLf & _
"T102" & vbCrLf
Public Const DefaultEndCodes As String = "G28G91X0Z0" & vbCrLf & _
"G90" & vbCrLf & _
"G52X0Y0Z0M5" & vbCrLf & _
"G08P0" & vbCrLf & _
"M30" & vbCrLf & _
"%"
Code: Select allPublic Function DoLeadIn(ByVal RapidWord As String, _
ByVal XStart As String, _
ByVal YStart As String, _
ByVal HNumber As String, _
ByVal SpindleWord As String, _
ByVal RoughSpeed As String, _
ByVal SafetyPlane As String, _
ByVal ZRapidFeedDepth As String) As String
Return RapidWord & "G17G55" & XStart & YStart & SpindleWord & "S" & RoughSpeed & vbCrLf & _
"G43" & HNumber & "Z" & SafetyPlane & vbCrLf & _
ZRapidFeedDepth & vbCrLf
End Function
Code: Select all Public Function DoLeadOut(ByVal RapidWord As String, _
ByVal SafetyPlane As String) As String
Return vbCrLf & RapidWord & SafetyPlane & vbCrLf
End Function
Obviously VB, (never used MEL before), mostly I just posted it for the g-code words. Basically, your script needs to slice the 3D surface along one axis, then traverse the line querying Maya for the surface-XYZ at each point...so a basic pseudo-program would:
> output start codes
> output first toolchange (if applicable)
> rapid to first lead-in
> perform lead-in
> walk surface, outputting [feed-word (i.e. 'G01')]XnYnZn for each point
> perform lead-out
> Z-up to safety plane
> rapid to next row
> repeat lead-in, traverse, lead-out, safety plane, next row...for each row
> output end codes
Sounds like a fun school project...good luck.
JD