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

!A
!A NAME:
!A
!A 	Scale: Non Uniform	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 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements are to
!B 		be scaled in.
!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 group ")



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]
DEG

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

ActivateUndo
stat= SetInputFormat("n4","")

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)
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:! 

Num_elements= GroupCount(Group)
Stat= GenerateVarName(WsVarRecordEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("SCALE: non 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_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(Egroup,Pc,V1,V2,V3)
Stat= AutoNameGroup(G1,Name$)

ActivateUndo
Stat= AdvanceUndoNumber("non uniform 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=DeleteEntityList(Group,G1)

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


