
! script name: vcontours.d/addcontzramp
! var_topic: add a z ramp along the contour.

!A
!A NAME:
!A
!A 	Z Ramp Contour		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script adds a ramp to a contour. The original contour is deleted.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick an element on the contour.
!B
!B 	DEPTH: Give amount of the ramp in z.
!B
!B 	RAMP ANGLE: Give the approximate ramp angle.
!B
!C NOTES:
!C
!C 	The Method appears as a free parameter.
!C
!C 	Method= 1  Ramp angle is interpreted as a length. Changes
!C 		direction between ramp and cut.
!C
!C 	Method= 2  Angle and depth calculate the length of ramp.
!C 		changes direction between ramp and cut.
!C
!C 	Method= 11  Ramp angle is interpreted as a length. Will follow
!C 		contour direction for a closed contour.
!C
!C 	Method= 21  Angle and depth calculate the length of ramp.
!C 		Will follow contour direction for a closed contour.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: add contour z ramp ")

DIM Answer$[256]
DIM Destination$[256]
DIM Contour$[256]
DIM Angle_var$[256]
DIM Depth_var$[256]
DIM Name$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

Method=2

ActivateUndo
Pick_contour: !
Contour=PickGroupEnt("PICK CONTOUR ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour
Stat=EntityNameCheck(Contour,Contour$)
IF NOT IsEntVariational(Contour) THEN
   Stat=SetInputFormat("a99","")
   Stat= GetValue("NON-VDM ENTITY. CANNOT USE ON NON VDM ENTITY ",Answer$)
   Stat=SetInputFormat("n4","")
   GOTO Leave
END IF

IF IsContClosed(Contour) THEN Method=21

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

Stat=SetInputFormat("n4","")
Ramp_angle=GetValue("RAMP ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)


Stat=GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("CONTOUR: Add Contour Z Ramp")
IF No_depth_var THEN
	V1= FreeParameter("Z Ramp Depth",Depth)
ELSE
	V1= FreeParameter("Z Ramp Depth",Depth_var$)
END IF
IF No_angle_var THEN
	V2= FreeParameter("Ramp angle",Ramp_angle)
ELSE
	V2= FreeParameter("Ramp angle",Angle_var$)
END IF
V3= FreeParameter("Feed factor",0.6)
V4= FreeParameter("Method",Method)
C1=AddContourZRamp(Contour$,V1,V2,V3,V4)
RecordFunctionOff
IF ValidGeometry(C1) THEN
	RecordFunctionOn
	Stat=AutoNameGroup(C1,Name$)
	Tool= GetAssocTool(Contour$)

	ActivateUndo
	Stat= AdvanceUndoNumber("add z ramp")
	Stat= AddGroupToUndo(WsUBDeleteMode,Contour$,1,WsTrue)

	Stat=DeleteGroup(Contour$,WsTrue)
	Stat=AssociateTool(C1,Tool)
	RecordFunctionOff
	Stat= PlotEntity(C1)
END IF
RecordFunctionOn
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord


Stat= AddGroupToUndo(WsUBCreateMode,C1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_contour

Leave:!
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

