
! script name: vcontours.d/radialslot
! var_topic: make a radial slot contour.

!A
!A NAME:
!A
!A 	Radial Slot contour		VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a radial slot contour.
!A
!A~ image location - images/radialslot.jpg
!B INSTRUCTIONS:
!B
!B 	START POINT: Pick the start point of the slot.
!B
!B 	END POINT: Pick the end point of the slot.
!B
!B	BASE RADIUS:  Input the base radius. This is the radius at
!B			the center of the slot.
!B
!B	SLOT RADIUS:  Input the slot radius. This is the radius of the
!B			circles at the ends of the slot.
!B
!C NOTES:
!C
!C	The radial slot is always created in the counterclockwise
!C	direction.
!C
!C	This csript can generate the following versions of a slot:
!C
!C		type= 1: Full slot, circle center to circle center.
!C		type= 2: Full slot, end to end.
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: radius slot contour ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Point1$[256]
DIM Point2$[256]
DIM Center$[256]
DIM Radius_var$[256]
DIM Base_var$[256]

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

ActivateUndo
Slot_type=1

Slot_loop:!

Ask_base_rad:Stat=SetInputFormat("n4=","")
Base_radius=InputRadius("BASE RADIUS ")
IF ExitScript(Destination$) THEN Leave
No_base_var= LastVariableInput(Base_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
	 IF NOT ValidDependency(C1) THEN Ask_base_rad
       	 No_base_var=0
       	 Stat= EntityNameCheck(C1,Base_var$)
END IF


Ask_radius:Stat=SetInputFormat("n4=","")
Stat= SetEqualsValue(Radius)
Radius=InputRadius("SLOT RADIUS ")
IF ExitScript(Destination$) THEN Leave
No_radius_var= LastVariableInput(Radius_var$)
C1= LastPickEnt
IF ValidGeometry(C1) THEN
	 IF NOT ValidDependency(C1) THEN Ask_radius
       	 No_radius_var=0
       	 Stat= EntityNameCheck(C1,Radius_var$)
END IF

Center_point:Stat=SetInputFormat("n4=","")
E1=PickEntity("CENTER POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Center_point
Pick_para= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E1,Center$)
P1= ParameterReturnPt(E1,Pick_para,Pick_return)
Stat=SetLastPoint(P1)
Stat= DeleteEntity(P1)


Pick_point2:Stat=SetInputFormat("n4=","")
Pick_point1:Stat=SetInputFormat("n4=","")
E1=PickEntity("START POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point1
Pick_para1= LastPickPara
Pick_return1= CurrPickReturn
Stat= EntityNameCheck(E1,Point1$)
P1= ParameterReturnPt(E1,Pick_para1,Pick_return1)
Stat=SetLastPoint(P1)
Stat= DeleteEntity(P1)


Pick_point2:Stat=SetInputFormat("n4=","")
E2=PickEntity("END POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_point2
Pick_para2= LastPickPara
Pick_return2= CurrPickReturn
Stat= EntityNameCheck(E2,Point2$)
P2= ParameterReturnPt(E2,Pick_para2,Pick_return2)
Stat=SetLastPoint(P2)
Stat= DeleteEntity(P2)



Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CONTOUR: Radial Slot")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeomCenter)
END SELECT
SELECT Pick_return1
CASE WsGeometryEnd
        P1= ParameterReturnPt(Point1$,Pick_para1,WsGeometryEnd)
CASE WsGeometryMid
        P1= ParameterReturnPt(Point1$,Pick_para1,WsGeometryMid)
CASE WsGeomCenter
        P1= ParameterReturnPt(Point1$,Pick_para1,WsGeomCenter)
END SELECT
SELECT Pick_return2
CASE WsGeometryEnd
        P2= ParameterReturnPt(Point2$,Pick_para2,WsGeometryEnd)
CASE WsGeometryMid
        P2= ParameterReturnPt(Point2$,Pick_para2,WsGeometryMid)
CASE WsGeomCenter
        P2= ParameterReturnPt(Point2$,Pick_para2,WsGeomCenter)
END SELECT
V1= FreeParameter("Type",Slot_type)
IF No_base_var THEN
	V2= FreeParameter("Base radius",Base_radius)
	IF No_radius_var THEN
		V3= FreeParameter("Slot_radius",Radius)
		C1= TwoPointRadialSlot(Pc,P1,P2,V2,V3,V1)
	ELSE
		C1= TwoPointRadialSlot(Pc,P1,P2,V2,Radius_var$,V1)
	END IF
ELSE
	IF No_radius_var THEN
		V3= FreeParameter("Slot_radius",Radius)
                C1= TwoPointRadialSlot(Pc,P1,P2,Base_var$,V3,V1)
        ELSE
                C1= TwoPointRadialSlot(Pc,P1,P2,Base_var$,Radius_var$,V1)
        END IF
END IF
Stat= AutoNameGroup(C1,Name$)
Stat= DeleteEntityList(Pc,P1,P2)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(C1)
Stat= PlotEntity(Center$)
Stat= PlotEntity(Point1$)
Stat= PlotEntity(Point2$)
IF NOT ValidGeometry(C1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("radial slot")
	Stat= AddGroupToUndo(WsUBCreateMode,C1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Slot_loop

Leave:!
Stat= DeleteEntityList(Pc,P1,P2)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
