
! script name: dyn_shapes.d/dynamicslot
! topic: slot contour

!A
!A NAME:
!A
!A 	Slot contour		
!A
!A DESCRIPTION:
!A
!A	This script constructs a slot contour.
!A
!A~ image location - images/slotcontour.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	RADIUS:  Input the radius.
!B
!C NOTES:
!C
!C		The  < > keys control the starting radius.
!C		The  [ ] keys control the ending radius.
!C		The  + - keys toggle through the slot types.
!C
!C	This script 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		type= 3: Upper half, circle center to circle center.
!C		type= 4: Upper half, end to end.
!C		type= 5: Lower half, circle center to circle center.
!C		type= 6: Lower half, end to end.
!C		type= 7: Full slot, flat end to circle center.
!C		type= 8: Full slot, flat end to circle end.
!C		type= 9: Full slot, flat end to flat end.
!C
!# see also - points.d/dyninput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: slot two points ")

DIM Destination$[256]
DIM Answer$[256]
REAL Params(0:10)


IF ARGC=2 THEN
        Answer$= UPC$(ARGV(1))
	slot_type= VAL(Answer$)
ELSE
        slot_sype=1
END IF


ActivateUndo
Start:!
Stat=SetPickMask(WsPickNoSurf)
Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_length2= GetDefault(WsDynamicLength2)
Dynamic_radius= GetDefault(WsDynRadiusDefault)
Stat= SetDefaults(WsDynamicLength1,Dynamic_radius)
Stat= SetDefaults(WsDynamicLength2,Dynamic_radius)

Ask_radius:Stat=SetInputFormat("n4=","")
        Radius=InputRadius("RADIUS")
        IF (ExitScript(Destination$)) THEN Leave
        Stat=SetRadiusEquals(Radius)
	Radius1= Radius
	Radius2= Radius
	Angle= 0.0

Cloop:!

Pick_axis:!
Stat=DynLabel("Start Radius:"&VAL$(Radius1)&":End Radius:"&VAL$(Radius2))
PlotOn
Stat=SetInputFormat("n4b","")
Ps=XyzInput("START POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Ps) THEN Pick_axis
Stat=SetLastPoint(Ps)

PlotOff
Length1= 2.0+ 2.0*Radius
Pe= PtIncrXyz(Ps,Length1,Length1,0.0)
Contour= SlotTwoPoints(Ps,Pe,Radius,Radius,Slot_type)
IF NOT ValidGeometry(Contour) THEN
	Stat= DeleteEntity(Ps)
	Stat= DeleteEntity(Pe)
	GOTO Pick_axis
END IF
Params(0)= Slot_type
Params(1)= Radius1
Params(2)= Radius2
Stat= MakeInvisible(Contour)
Stat= MakeInvisible(Ps)
Stat= MakeInvisible(Pe)
PlotOn

Vnum= LastPickView
Num_params=3
Stat=SetInputFormat("n4b","")
Stat=DynamicShape(Vnum,Contour,Ps,Pe,WsDynamicSlot,"PICK END POINT ",Params,Num_params)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteGroup(Contour,WsTrue,WsTrue)
	Stat=DeleteEntity(Ps)
        Stat=DeleteEntity(Pe,WsTrue)
        IF Destination$= "BACKUP" THEN Pick_axis
        GOTO Leave
END IF
Slot_type= Params(0)
Radius1= Params(1)
Radius2= Params(2)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF ValidGeometry(Contour) THEN
        Stat=AutoNumberCont(Contour)
	Stat= PlotEntity(Contour)

	ActivateUndo
	Stat= AdvanceUndoNumber("slot")
	Stat= AddGroupToUndo(WsUBCreateMode,Contour,WsTrue,WsFalse)
END IF

GOTO Pick_axis

Leave:!
Stat=DynLabel("")
Stat=SetPickMask(WsPickGeometry)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat= SetDefaults(WsDynamicLength1,Dynamic_length1)
Stat= SetDefaults(WsDynamicLength2,Dynamic_length2)

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
	IF Destination$= "BACKUP" THEN Start
	LOAD Destination$
END IF
END
