
! script name: macros.d/slot
! EXAMPLE: slot of specified lenght, width, and angle

!A
!A NAME:
!A 	Slot
!A
!A DESCRIPTION:
!A 	This script creates a slot of specified length, width and angle.
!A
!B INSTRUCTIONS:
!B 	SLOT END ABS X,Y: Enter the X,Y coordinates of the end of the slot.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	LENGTH OF SLOT: Enter the length of the slot.
!B
!B 	WIDTH OF SLOT: Enter the width of the slot.
!B
!B 	SLOT ANGLE: Enter the angle the slot is to be oriented at.
!B
!# see also - points.d/xyzinput.hlp

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

DIM Answer$[256]
DIM Destination$[256]

DEG

DeActivateUndo
Slot_loop:!

Stat=SetInputFormat("n4=","")
Pc=XyzInput("SLOT END ",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave

Slot_length=GetValue("LENGTH OF SLOT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Slot_width=GetValue("WIDTH OF SLOT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Slot_angle=InputAngle("SLOT ANGLE")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetAngleEquals(Slotangle)

Xcen=XPointValue(Pc)
Ycen=YPointValue(Pc)
Radius=Slot_width/2
R1=Radius
R2=Slot_length-Radius
X1=Xcen+R1*COS(Slot_angle)
Y1=Ycen+R1*SIN(Slot_angle)

X2=Xcen+R2*COS(Slot_angle)
Y2=Ycen+R2*SIN(Slot_angle)

Tp1=Type3(3,X1,Y1,X2,Y2,Radius,Radius)
IF (NOT ValidGeometry(Tp1)) THEN Leave
Tp2=Type3(3,X2,Y2,X1,Y1,Radius,Radius)
IF (NOT ValidGeometry(Tp2)) THEN Leave
Stat=JoinTypes(Tp1,Tp2)
Stat=CloseType(Tp2)
Contour=TypesContour(Tp2,1)

Stat=DeleteEntity(Pc)

GOTO Slot_loop

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