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

!A
!A NAME:
!A
!A 	3D Rotate 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 	PICK GROUP TO BE ROTATED: Pick an element on the group to be rotated.
!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 group ")

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

Highlight_color= 3
Stat= SetDefaults(WsSelectedEntPen,Highlight_color)
Start: !
ActivateUndo

Group=CreateGroup("TEMP")
Extras$= ""

LOOP
        stat= SetInputFormat("a1",",P,B,")
        C1=PickGroupEnt("PICK GROUP TO BE ROTATED"&Extras$,0,Answer$)
        IF ExitScript(Destination$) THEN Leave
        EXIT IF Answer$= "P"
        IF Answer$="B" THEN
                Num1=GroupCount(Group)
                C1=GroupElement(Group,Num1)
                IF Num1 THEN Stat= RemoveFromGrp(Group,Num1)
		Stat= SetSelectedFlag(C1,WsFalse)
                Stat= PlotEntity(C1)
                IF Num1=1 THEN Extras$= ""
        ELSE
                IF ValidGeometry(C1) THEN
                        N1= ElementGrpNum(Group,C1)
                        IF NOT N1 THEN
                                Stat=AddToGroup(Group,C1)
				Stat= SetSelectedFlag(C1,WsTrue)
                		Stat= PlotEntity(C1)
                        END IF
                        Extras$=", Backup , Proceed "
                END IF
        END IF

END LOOP

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

stat= SetInputFormat("n4","")

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


ActivateUndo
Stat= AdvanceUndoNumber("rotate")
Num1= GroupCount(Group)
FOR J= 1 TO Num1
        C1= GroupElement(Group,J)
	FOR I=1 TO Number
		Ang=I*Angle
		PlotOff
		C2= CopyGroup(C1)
		PlotOn
		Axis_trans= RotAboutAxisTrans(Axis_line,Ang)
        	Stat=TransGroupTrans(C2,Axis_trans)
		Stat=AutoNumber(C2)
		Stat= SetSelectedFlag(C2,WsFalse)
		Stat= PlotEntity(C2)
		Stat= AddGroupToUndo(WsUBCreateMode,C2,1,WsTrue)
	NEXT I
NEXT J
Stat= SetSelectedFlag(Group,WsFalse)
Stat= PlotEntity(Group)
Stat= DeleteEntity(Group)
Stat= DeleteEntity(G1)

PlotAll
GOTO Start

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

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