
! script name: dyn_shapes.d/dynradialslot
! 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
!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		In the dynamic mode the < > keys control the Base radius.
!C		The [ ] keys control the Slot Radius.
!C		The + - keys toggle between the 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
!# see also - points.d/dyninput.hlp

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

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


Slot_type=1


ActivateUndo
Start:!
Stat=SetPickMask(WsPickNoSurf)
Dynamic_length1= GetDefault(WsDynamicLength1)
Dynamic_length2= GetDefault(WsDynamicLength2)
Dynamic_angle1= GetDefault(WsDynamicAng1Incr)
Dynamic_angle2= GetDefault(WsDynamicAng2Incr)

Dynamic_radius= GetDefault(WsDynRadiusDefault)
Dynamic_angle= GetDefault(WsDynAngleDefault)

Stat= SetDefaults(WsDynamicLength1,Dynamic_radius)
Stat= SetDefaults(WsDynamicLength2,Dynamic_radius)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle)
Stat= SetDefaults(WsDynamicAng2Incr,5)

Ask_base_rad:Stat=SetInputFormat("n4=","")
Base_radius=InputRadius("BASE RADIUS ")
IF ExitScript(Destination$) THEN Leave

Ask_radius:Stat=SetInputFormat("n4=","")
Stat= SetEqualsValue(Radius)
Radius=InputRadius("SLOT RADIUS ")
IF ExitScript(Destination$) THEN Leave

Center_point:Stat=SetInputFormat("n4=","")
Pc=XyzInput("CENTER POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pc) THEN Center_point

Cloop:!

Pick_axis:!
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
Angle= 0.0
Length1= 2.0+ 2.0*Radius+ 2.0*Chamfer
Pe= PtIncrXyz(Ps,Length1,Length1,0.0)
Contour= TwoPointRadialSlot(Pc,Ps,Pe,Base_radius,Radius,Slot_type)
IF NOT ValidGeometry(Contour) THEN 
	Stat= DeleteEntity(Ps)
	Stat= DeleteEntity(Pe)
	GOTO Pick_axis
END IF
Params(0)= Trapezoid_type
Params(1)= Base_radius
Params(2)= Radius
Params(3)= XPointValue(Pc)
Params(4)= YPointValue(Pc)
Params(5)= ZPointValue(Pc)

Stat= MakeInvisible(Contour)
Stat= MakeInvisible(Ps)
Stat= MakeInvisible(Pe)
Stat= MakeInvisible(Pc)
PlotOn

Vnum= LastPickView
Num_params=8
Stat=SetInputFormat("n4b","")
Stat=DynamicShape(Vnum,Contour,Ps,Pe,WsDynRadialSlot,"PICK END POINT ",Params,Num_params)
IF (ExitScript(Destination$)) THEN
        Stat=DeleteGroup(Contour,WsTrue,WsTrue)
	Stat=DeleteEntity(Ps)
        Stat=DeleteEntity(Pe,WsTrue)
        Stat=DeleteEntity(Pc,WsTrue)
        IF Destination$= "BACKUP" THEN Pick_axis
        GOTO Leave
END IF
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Pc)
IF ValidGeometry(Contour) THEN
        Stat=AutoNumberCont(Contour)
	Stat= PlotEntity(Contour)

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

GOTO Ask_base_rad

Leave:!
Stat=SetPickMask(WsPickGeometry)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(Pc)
Stat= SetDefaults(WsDynamicAng1Incr,Dynamic_angle1)
Stat= SetDefaults(WsDynamicAng2Incr,Dynamic_angle2)
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
