
! script name: rims.d/scalegroup
! topic: scale group uniformly

!A
!A NAME:
!A
!A 	Uniform - Delete Original
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements to be scaled uniformly.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick
!B 		the view that elements are to be scaled in.
!B
!B 	SCALE FACTOR: Enter the scale factor to be used.
!B
!B 	CENTER ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates of the point which is the center
!B 		of scaling.  NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: Uniform - Delete Original ")

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

ActivateUndo
stat= SetInputFormat("n4","")
Active_workplane=0
Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane=1

StdWorkplane

Group=CreateGroup("TEMP")

Scale_copy= 0 ! 1 will not delete original


Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF (ExitScript(Destination$)) THEN Leave

Stat=PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(1.0)
Scale_factor= GetValue("SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Center= XyzInput("CENTER",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Scale_group:! 
G1=ScaleGroup(Group,center,Scale_factor)

IF (ValidGeometry(G1)) THEN
        Stat=Highlight(G1,WsHighlightPen,WsDirArrowOff)
END IF

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

Stat=DeleteEntity(G1)
Stat=DeleteEntity(Center)
IF Scale_copy THEN
	Stat=DeleteEntity(Group)
ELSE
	Stat= AddGroupToUndo(WsUBDeleteMode,Group,2,WsTrue)
	Stat=DeleteGroup(Group,1)
END IF

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Group)
Stat=DeleteEntity(G1)

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


