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

!A
!A NAME:
!A
!A 	Core / Cavity
!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 GROUP TO BE INVERTED: Pick an element on the group to be inverted.
!B
!C NOTES:
!C
!C 	Nothing is done to the normals on the inverted group.  The group
!C 	should be unlinked and a new group should be made to get the correct
!C 	normals.
!C

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

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

ActivateUndo
Start: !

stat= SetInputFormat("n4","")

C1=PickGroupEnt("PICK GROUP TO BE INVERTED")
IF ExitScript(Destination$) THEN Leave

Pt= PointXYZ(0.0,0.0,0.0)

T1=AngleTransform(Pt,0,0,0,WsWorkplaneVals)
T2=InvertInPlane(T1)
PlotOff
C2= CopyGroup(C1)
PlotOn
Stat=TransGroupTrans(C2,T2,0,1)
Stat=AutoNumber(C2)
Stat= GroupName(C1,Answer$)
Stat= ChangeGrpName(C2,Answer$&" inversion")

ActivateUndo
Stat= AdvanceUndoNumber("invert")
Stat= AddGroupToUndo(WsUBCreateMode,C2,1,WsTrue)

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
