
! script name: invert.d/3dinvdelbox
! topic: 3D invert boxed group of entities and delete original

!A
!A NAME:
!A
!A 	3D Invert and Delete Boxed Group
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities or a single entity to be
!A 	inverted 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 		inverted in.
!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 invert.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B	X AXIS INVERSION ANGLE: X axis angle of the plane to invert about.
!B
!B	Y AXIS INVERSION ANGLE: Y axis angle of the plane to invert about.
!B
!B	Z AXIS INVERSION ANGLE: Z axis angle of the plane to invert about.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 3d invert and delete boxed group ")

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

ActivateUndo
Start: !

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 ",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

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

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

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

T1=AngleTransform(Pt,Xangle,Yangle,Zangle,WsWorkplaneVals)
T2=InvertInPlane(T1)

G1=TransformGroup(Group,T2,"TEMP1")

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

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

Stat= DeleteEntity(Pt)
Stat= DeleteEntity(Group)
Stat= DeleteEntity(G1)

PlotAll
GOTO Start

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

!   TransformCleanUp

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