
! script name: pksolids.d/pkrectangle
! solids: construct a rectangle sheet body in the current workplane.

!A
!A NAME:
!A
!A 	Rectangle
!A
!A DESCRIPTION:
!A
!A 	This script will construct a rectangle sheet body 
!A
!B INSTRUCTIONS:
!B
!B	LENGTH: Enter the length of the rectangle
!B
!B	WIDTH: Enter the width of the rectangle
!B
!B	LOCATION POINT: Input the location of the center of the rectangle.
!B
!B	X AXIS DIRECTION POINT: Input a point giving the direction of the
!B 		x axis of the rectangle.
!B
!B	Y AXIS DIRECTION POINT: Input a point giving the direction of the
!B 		y axis of the rectangle.
!B
!# see also - htdocs/help.d/parasolids.htm

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

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


ActivateUndo
Units= CurrentUnits
IF Units= WsMetric THEN
        Xlength= 120
        Ylength= 120
ELSE
        Xlength= 5
        Ylength= 5
END IF

Stat= GLPlotOn
Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Xlength)
XLength=InputDepth("LENGTH")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Ylength)
YLength=InputDepth("WIDTH")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4","")
P1=XyzInput("LOCATION POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave
Stat= SetLastPoint(P1)

Stat=SetInputFormat("n4","")
P2=XyzInput("X AXIS DIRECTION POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4","")
P3=XyzInput("Y AXIS DIRECTION POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave

WPKClearErrorFlag
C1=WPKRectangle(P1,P2,P3,Xlength,Ylength)

Stat= DeleteEntity(P1)
Stat= DeleteEntity(P2)
Stat= DeleteEntity(P3)

ActivateUndo
Stat= AdvanceUndoNumber("rectangle sheet body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Cloop

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