
! script name: 3dmacros.d/taperedbox
! EXAMPLE: create a rectangular cavity with rounded corners and tapered sides

!A
!A NAME:
!A
!A 	Tapered Box
!A
!A DESCRIPTION:
!A
!A 	This script creates a rectangular cavity with rounded corners and
!A 	tapered sides.
!A
!B INSTRUCTIONS:
!B
!B 	RECTANGLE CENTER ABS X,Y: Enter the X,Y coordinates of the rectangles'
!B 		center.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	X LENGTH OF RECTANGLE: Enter the length of the rectangle, parallel to
!B 		the X axis.
!B
!B 	Y WIDTH OF RECTANGLE: Enter the width of the rectangle, parallel to the
!B 		Y axis.
!B
!B 	CORNER RADIUS: Enter the radius to be used in all corners.
!B
!B 	CAVITY DEPTH: Enter the depth of the cavity.
!B
!B 	TAPER ANGLE: Enter the angular taper of the sides of the cavity.
!B
!# see also - points.d/xyzinput.hlp

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

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

ActivateUndo
Rect_loop:!
Stat=SetInputFormat("n4","")

Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

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=SetEqualsValue(Depthr)
Depth=GetValue("CAVITY DEPTH",Answer$)
IF ExitScript(Destination$) THEN Leave
Depthr=Depth

Stat=SetEqualsValue(Taperr)
Taper=InputAngle("TAPER ANGLE")
IF ExitScript(Destination$) THEN Leave
Taperr=Taper

Stat=SetRadiusEquals(Radius)

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

Angle=0
Surf2= TaperedBox(Xcen,Ycen,Xlen,Ywid,Depth,Radius,Taper,Angle)

ActivateUndo
Stat= AdvanceUndoNumber("ruled surf")
Stat= AddItemToUndo(WsUBCreateMode,Surf2)

Stat=DeleteEntity(Pc)
GOTO Rect_loop

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