
! script name: rotate.d/3drotatebox
! topic: 3D rotate boxed group of entities

!A
!A NAME:
!A
!A 	3D Rotate Boxed Group
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities or a single entity to be
!A 	rotated and the option of the original being deleted.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements are to be
!B 		rotated in.
!B
!B 	ROTATION ANGLE ABOUT AXIS: Enter the angular rotation amount around
!B 		the axis.
!B
!B 	NUMBER OF TIMES: Enter the number of times the rotation process
!B 		should be repeated.
!B
!B 	PICK AXIS LINE: Pick the axis line to be used as the reference for
!B 		the rotation.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: 3d rotate boxed group ")

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

Start: !
ActivateUndo

stat= SetInputFormat("n4","")

Group=CreateGroup("TEMP")


Vnum= LastPickView
Stat=PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave

IF NOT ValidGeometry(Group) THEN 
	GOTO Start
ELSE
	IF NOT GroupCount(Group) THEN Start
END IF

Stat=SetEqualsValue(Angle)
Angle=GetValue("ROTATION ANGLE ABOUT AXIS",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetEqualsValue(1)
Stat=SetInputFormat("n0=","")
Number=GetValue("NUMBER OF TIMES",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Number=0 THEN Start

Axis_line=PickSpecificEnt("PICK AXIS LINE ",WsPickLines)
IF ExitScript(Destination$) THEN Leave


G1= RotGrpAboutAxis(Group,Axis_line,Angle,Number)

ActivateUndo
Stat= AdvanceUndoNumber("rotate")
Stat= AddGroupToUndo(WsUBCreateMode,G1,2,WsTrue)

Stat= DeleteSubGroups(G1)
Stat=DeleteEntity(Group)
Stat=PlotEntity(Axis_line)

PlotAll
GOTO Start

Leave: !
stat= SetInputFormat("n4","")
Stat= DeleteEntity(Group)
Stat= DeleteEntity(G1)

IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
