
! script name: v3dcpaths.d/cpthcuthelixramp
! var_topic: helix ramp leadin  into a cutterpath cut

!A
!A NAME:
!A
!A 	3D Modify: Insert Helical Z Ramp Leadin Cut   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script inserts a Helical z ramp move into a 3D cutterpath.
!A
!B INSTRUCTIONS:
!B
!B	RAMP DEPTH: Input the z length of the ramp move.
!B
!B	RAMP ANGLE: Input the angle which the cutter is feeding down along
!B			the ramp.
!B
!B 	PICK CUTTERPATH CUT: Pick the cutterpath. 
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function:  cutterpath helical z ramp ")

DIM Destination$[256]
DIM Answer$[256]
DIM Angle_var$[256]
DIM Ramp_var$[256]
DIM Dia_var$[256]
DIM Depthcut_var$[256]
DIM Depth_var$[256]
DIM Cpath_name$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Method=2
Ramp_angle= 5

Helix_dia:!
Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(Diar/2)
Helix_dia=InputRadius("DIAMETER OF HELIX",WsDiaInput)
IF (ExitScript(Destination$)) THEN Leave
No_dia_var= LastVariableInput(Dia_var$)
Diar= Helix_dia


Stat=SetInputFormat("n4","")
Depth=GetValue("RAMP DEPTH")
IF (ExitScript(Destination$)) THEN Leave
No_depth_var= LastVariableInput(Depth_var$)

Depth_cut: IF Method=1 THEN
        Depth_cut=NamedVarVal("depth of cut",WsSystemVars,0.0)
        Stat=SetEqualsValue(Depth_cut)
        Stat=SetInputFormat("n4=","")
        Depth_cut=GetValue("DEPTH OF CUT",Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        Depth_cut=ABS(Depth_cut)
        Vdepth=CreateVariable("depth of cut",WsSystemVars,Depth_cut)
        No_depthcut_var= LastVariableInput(Depthcut_var$)
        Stat=SetCurrentColor(Pen_color)
ELSE
        Depth_cut= Depth
        No_depthcut_var=1
END IF
Ramp_angle: IF Method=2 THEN
        Stat=SetInputFormat("n4=","")
        Stat=SetEqualsValue(Ramp_angle)
        Ramp_angle=GetValue("RAMP ANGLE")
        IF (ExitScript(Destination$)) THEN Leave
        No_ramp_var= LastVariableInput(Ramp_var$)
ELSE
        Ramp_angle= 5
        No_ramp_var=1
END IF

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Start_angle)
Start_angle=GetValue("START ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)

Pick_loop:!
Stat=SetInputFormat("n4","")
Cpath=PickEntity("PICK CUTTERPATH CUT ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Cpath) THEN Pick_loop
Stat= EntityNameCheck(Cpath,Cpath_name$)
Etype=EntityType(Cpath)
IF Etype<>WsCPathFileEnt THEN Pick_loop
T=LastPickPara
Path=INT(T)

DeActivateUndo
RecordFunctionOn
Stat= RecordDescr("MODIFY CUTTERPATH: Insert helical z ramp on cut")
IF No_dia_var THEN
        V1= FreeParameter("Helix diameter",Helix_dia)
ELSE
        V1= FreeParameter("Helix diameter",Dia_var$)
END IF
IF No_depth_var THEN
        V2= FreeParameter("Z Ramp Depth",Depth)
ELSE
        V2= FreeParameter("Z Ramp Depth",Depth_var$)
END IF
IF No_depthcut_var THEN
        V3= FreeParameter("Depth of cut",Depth_cut)
ELSE
        V3= FreeParameter("Depth of cut",Depthcut_var$)
END IF
IF No_ramp_var THEN
        V4= FreeParameter("Ramp angle",Ramp_angle)
ELSE
        V4= FreeParameter("Ramp angle",Ramp_var$)
END IF
IF No_angle_var THEN
        V5= FreeParameter("Start angle",Start_angle)
ELSE
        V5= FreeParameter("Start angle",Angle_var$)
END IF
V6= FreeParameter("Feed factor",0.6)
V7= FreeParameter("Direction",WsCCW)
V8= FreeParameter("Method",Method)
V9= FreeParameter("Path number",Path)
Stat= AddCpathHelixRamp(Cpath_name$,V1,V2,V4,V3,V5,V6,V7,V8,v9)
RecordFunctionOff
CloseVarRecord

Stat=PlotEntity(Cpath)
GOTO Pick_loop

Leave:!
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
