
! script name: rotate.d/2drotdelbox
! topic: 2D rotate boxed group of entities and delete original

!A
!A NAME:
!A
!A 	2D Rotate and Delete 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 	REFERENCE POINT ABS X,Y: Enter the X,Y coordinates of the point
!B 		to be used as the reference for the rotate.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ROTATION ANGLE: Enter the angular amount the entities should be
!B 		rotated.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 2d rotate and delete 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

Pt=XyzInput("REFERENCE POINT ",WsXyOnly)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4="," ")
Stat=SetEqualsValue(Angle)
Angle=InputAngle("ROTATION ANGLE")
IF ExitScript(Destination$) THEN Leave


G1= PlaneRotateGroup(Group,Pt,Angle)
Stat= DeleteEntity(Pt,WsTrue)

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

Stat= DeleteEntity(G1)
Stat=Unlink(Group)
Stat=DeleteGroup(Group,1)

PlotAll
GOTO Start

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

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