
! script name: vscale.d/nonunfrmcont
! var_topic: different scale factors in XYZ

!A
!A NAME:
!A
!A 	Non Uniform Scale Group	 VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements to have a different scale
!A 	factor in X, Y, and Z.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR GROUP TO SCALE: Pick the contour to copy and scale
!B
!B 	X SCALE FACTOR: Enter the X scale factor.
!B
!B 	Y SCALE FACTOR: Enter the Y scale factor.
!B
!B 	Z SCALE FACTOR: Enter the Z 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
!C NOTE:
!C
!C 	Dimensions, Text, and Arrows cannot be non uniform scaled.  Circles,
!C 	Ellipses, Cubic splines are converted to NURBS for non uniform scaling.
!C 	Holes are scaled in XYZ position, however the diameter, depth, and
!C 	orientation are unchanged.  Cubic and Nurb Surfaces remain as Cubic
!C 	and Nurb Surfaces.  3D Solids are converted into Scaled Solid Entities
!C 	which are solids with non-uniform scaling parameters.
!C
!# see also - points.d/xyzinput.hlp

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

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Element$[256]
DIM Center$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_var$[256]
DIM Cont_name$[256]
DEG

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

ActivateUndo
Start:!
Stat= SetInputFormat("n4","")
Group=PickGroupEnt("PICK CONTOUR GROUP TO SCALE ")
IF ExitScript(Destination$) THEN Leave

Stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(1.0)
Xscale= GetValue("X SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_x_var= LastVariableInput(x_var$)

Stat= SetEqualsValue(1.0)
Yscale= GetValue("Y SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_y_var= LastVariableInput(y_var$)

Stat= SetEqualsValue(1.0)
Zscale= GetValue("Z SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave
No_z_var= LastVariableInput(z_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_x_var THEN
	V1= FreeParameter("X scale",Xscale)
ELSE
	V1= FreeParameter("X scale",X_var$)
END IF
IF No_y_var THEN
	V2= FreeParameter("Y scale",Yscale)
ELSE
	V2= FreeParameter("Y scale",Y_var$)
END IF
IF No_z_var THEN
	V3= FreeParameter("Z scale",Zscale)
ELSE
	V3= FreeParameter("Z scale",Z_var$)
END IF
G1=NonUnfrmScaleGrp(Cont_name$,Pc,V1,V2,V3)
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


