
! script name: rotate.d/3drotdelent
! 3dtopic: 3D rotate single entity and delete original

!A
!A NAME:
!A
!A 	3D Rotate and Delete 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,Z: Enter the X,Y,Z coordinates of the point
!B 		to be used as the reference for the rotate.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B	X AXIS ROTATION: Angular amount around the X Axis
!B
!B	Y AXIS ROTATION: Angular amount around the Y Axis
!B
!B	Z AXIS ROTATION: Angular amount around the Z Axis
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 3d rotate and delete 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
Stat=SetInputFormat("n4"," ")

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

Stat=SetInputFormat("n4="," ")
Stat=SetEqualsValue(Xangle)
Xangle=GetValue("X AXIS ROTATION  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(Yangle)
Yangle=GetValue("Y AXIS ROTATION  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetEqualsValue(Zangle)
Zangle=GetValue("Z AXIS ROTATION  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave


E2= Angles3dRotEnt(E1,Pt,Xangle,Yangle,Zangle)

ActivateUndo
Stat= AdvanceUndoNumber("rotate")
Stat= AddItemToUndo(WsUBCreateMode,E2)
Stat= AddItemToUndo(WsUBDeleteMode,E1)

Stat= UnLink(E1)
Stat= DeleteEntity(E1)
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
