
! script name: macros.d/rectangle
! EXAMPLE: construct rectangle with corner radii

!A
!A NAME:
!A
!A 	Rectangle
!A
!A DESCRIPTION:
!A
!A 	This script constructs a rectangle with corner radii.
!A
!B INSTRUCTIONS:
!B
!B 	RECTANGLE CENTER ABS X,Y: Enter the X,Y coordinates of the center
!B 		of the rectangle.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	X LENGTH OF RECTANGLE: Enter the length of the rectangle.
!B
!B 	Y WIDTH OF RECTANGLE: Enter the width of the rectangle.
!B
!B 	CORNER RADIUS: Enter the radius to be used in all corners of the
!B 		rectangle.
!B
!# see also - points.d/xyzinput.hlp

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

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

DeActivateUndo
Rect_loop:!

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

Stat=SetEqualsValue(Xlenr)

Xlen=GetValue("X LENGTH OF RECTANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Xlenr=Xlen

Stat=SetEqualsValue(Ywidr)

Ywid=GetValue("Y WIDTH OF RECTANGLE",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Ywidr=Ywid

Radius=InputRadius("CORNER RADIUS")
IF (ExitScript(Destination$)) THEN Leave

Stat=SetRadiusEquals(Radius)

Xcen=XPointValue(Pc)
Ycen=YPointValue(Pc)

Angle=0
Centerstart= WsFalse
Contour= RectangleContour(Xcen,Ycen,Xlen,Ywid,Radius,Angle,Centerstart)

IF ValidGeometry(Contour) THEN
	Stat=AutoNumberCont(Contour)
END IF


Stat=DeleteEntity(Pc)

GOTO Rect_loop

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