
! script name: vscale.d/scalegroup
! var_topic: scale group uniformly

!A
!A NAME:
!A
!A 	Scale: Uniform	VARIATIONAL
!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 the view that elements are to be
!B 		scaled in.
!B
!B 	CENTER ABS X,Y,Z: Enter the X,Y,Z coordinates of the point which is
!B 		the center of scaling.  NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: scale group ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Center$[256]
DIM Element$[256]
DIM Scale_var$[256]
DEG

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

stat= SetInputFormat("n4","")

ActivateUndo

Group=CreateGroup("TEMP")

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
No_scale_var= LastVariableInput(scale_var$)

Ref_point:E2=PickEntity("CENTER POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E2) THEN Ref_point
T= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E2,Center$)
Pc= ParameterReturnPt(E2,T,Pick_return)

Scale_group:!
Num_elements= GroupCount(Group)
Stat= GenerateVarName(WsVarRecordEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("SCALE: Uniform scale ")
Egroup= CreateGroup("Picked Entities")

FOR I=1 TO Num_elements
RecordFunctionOff
        E1= GroupElement(Group,I)
        Stat= EntityNameCheck(E1,Element$)
        IF ValidDependency(E1,WsFalse) THEN
                RecordFunctionOn
                Stat= AddToGroup(Egroup,Element$)
                RecordFunctionOff
        END IF
NEXT I
RecordFunctionOn
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
IF No_scale_var THEN
        V1= FreeParameter("Scale factor",Scale_factor)
ELSE
        V1= FreeParameter("Scale factor",Scale_var$)
END IF
G1=ScaleGroup(Egroup,Pc,V1)
Stat= AutoNameGroup(G1,Name$)
ActivateUndo
Stat= AdvanceUndoNumber("scale")
Stat= AddGroupToUndo(WsUBModifyMode,Egroup,0,WsTrue)
Stat= AddGroupToUndo(WsUBCreateMode,G1,0,WsTrue)
Stat=HideEntity(Egroup)
Stat=DeleteEntityList(G1,Egroup,Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
Stat=DeleteEntity(Group)


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

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


