
! script name: vscale.d/scalecontour
! var_topic: scale contour

!A
!A NAME:
!A
!A 	Scale Group	 VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements to be scaled.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR GROUP TO SCALE: Pick the contour to copy and scale
!B
!B 	SCALE FACTOR: Enter the scale factor.
!B
!B 	CENTER ABS X,Y,Z: Enter the X,Y,Z coordinates of the point which
!B 		is the center of scaling.  NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

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

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

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

stat= SetInputFormat("n4","")

ActivateUndo
Start:!
Group=PickGroupEnt("PICK CONTOUR GROUP TO SCALE ")
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(x_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:! 

Stat= EntityNameCheck(Group,Cont_name$)
Stat= GenerateVarName(WsVarRecordEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("SCALE: non uniform scale ")
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(Cont_name$,Pc,V1)
Stat= AutoNameGroup(G1,Name$)
ActivateUndo
Stat= AdvanceUndoNumber("scale")
Stat= AddGroupToUndo(WsUBCreateMode,G1,0,WsTrue)
Stat=DeleteEntity(Pc)
RecordFunctionOff
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Start

Leave:!
TransformCleanUp
stat= SetInputFormat("n4","")
Stat=DeleteEntity(G1)
IF NOT LEN(Destination$) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


