I haven't done this in Mach4 yet.. But I have used this on pipe coping machines before and it shouldn't be hard to rewrite for mach4. All the API calls should be straight forward to do this.
Diam = Param1() * 3.14159265358
'Position ' Heigth ' W ' H
Begin Dialog Dialog1 120,96,"Set Part Diameter"
OKButton 15,75,40,14
CancelButton 65,75,40,14
GroupBox 12,8,97,62,"Change Part Diameter",.GroupBox1
Text 32,24,70,12,"Current Part Diameter:"
Text 28,55,80,12,"Press OK to continue."
TextBox 30,35,60,12,.Width
End Dialog
StepsPerAxisY = 1960000 'Steps per rotary turn
KernalSpeed = 400000 'Mach3 Kernal Speed in ports and pins
CurStepsPer = GetParam("StepsPerAxisY")
If Diam < 0 Then
Dim Dlg1 As Dialog1
Dlg1.Width = Round(StepsPerAxisY / CurStepsPer/3.14159265358,8)
Button = Dialog (Dlg1)
Diam = Dlg1.Width*3.14159265358
End If
'If Button = 0 Then
' DoOEMButton(1003)
' Exit Sub
'Else
NewPPR = StepsPerAxisY / Diam ' New Steps per for motor tuning
NewVel = (KernalSpeed / NewPPR) * 60
Call SetParam("VelocitiesY", (NewVel / 60))
Call SetParam("StepsPerAxisY", NewPPR)
'Message("Part width set... Scaling set to: " & Round(StepsPerAxisX / CurStepsPer,4))
'End If
'Must Reset To Update Mach Settings
If Not GetOEMLED(800) Then
DoButton(21)
Sleep(250)
End If
If GetOEMLED(800) Then
DoButton(21)
End If
Andrew with MachMotion