
! script name: rotate.d/2drotateent
! topic: 2D rotate single entity

!A
!A NAME:
!A
!A 	2D Rotate Entity
!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 ELEMENT TO BE ROTATED: Pick the element to be rotated.
!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
!B 	NUMBER OF TIMES: Enter the number of times the rotation process
!B 		should be repeated.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 2d rotate entity ")

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

Start: !
ActivateUndo

stat= SetInputFormat("n4","")

E1= PickEntity("PICK ELEMENT TO BE ROTATED")
IF (ExitScript(Destination$)) THEN Leave

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

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


E2= PlaneRotateEntity(E1,Pt,Angle,Number)

ActivateUndo
Stat= AdvanceUndoNumber("rotate")
IF (Number> 1)  THEN
	Stat= AddGroupToUndo(WsUBCreateMode,E2,2,WsTrue)
	Stat= DeleteEntity(E2)
ELSE
	Stat= AddItemToUndo(WsUBCreateMode,E2)
END IF
Stat= DeleteEntity(Pt,WsTrue)

PlotAll
GOTO Start

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

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