
! script name: invert.d/3dinvertmulti
! topic: 3D invert picked group of entities

!A
!A NAME:
!A
!A 	3D Invert Picked 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 	PICK ELEMENT, PROCEED: Pick one of the elements to be inverted.
!B 		The question will repeat until "PROCEED" is answered.
!B 		All elements picked will then be inverted.
!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 picked group ")

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

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

stat= SetInputFormat("n4","")

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

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

END LOOP

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)

Stat= SetSelectedFlag(Group,WsFalse)
G1=TransformGroup(Group,T2,"TEMP1")

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

Stat= PlotEntity(G1)
Stat=DeleteEntity(G1)
Stat= PlotEntity(Group)

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

GOTO Start

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

!   TransformCleanUp

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