
! script name: pkgroups.d/pkscalegroup
! solids: scale a group of faces within a solid body

!A
!A NAME:
!A
!A 	Scale Face Group
!A
!A DESCRIPTION:
!A
!A 	This script will uniformly scale a face group about a reference point.
!A
!A~ image location - images/pkscalefacegrp.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK GROUP TO BE SCALED: Pick the group.
!B
!B 	SCALE FACTOR: Enter the scale factor.
!B
!B 	REFERENCE POINT: Input the reference point.
!B
!C NOTES:
!C
!C      Scaling faces within a body creates special problems. When
!C      the faces are scaled they often change form from analytic
!C      surfaces to nurb surfaces. Nurb surfaces are not easily extended
!C      to join with the remaining faces in the body.
!C
!C      Do not use scaling to change the diameter of a cylindrical or
!C      conical hole. Even uniform scaling will change circle edges
!C      into nurb curves.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: scale face group")

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

ActivateUndo

Scale_factor= 1.0

Stat= GLPlotOn
Pick_group:!
E1=WPKPickEntity("PICK GROUP TO BE SCALED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_group
G1= WPKContainingGroup(E1,1,WsTrue)
IF NOT WPKIsEntity(G1) THEN Pick_group

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

Pc=XyzInput("REFERENCE POINT ",WsXyzInput)
IF ExitScript(Destination$) THEN Leave
Stat= SetLastPoint(Pc)

T1= ScaleTransform(Pc,Scale_factor)

WPKClearErrorFlag
Stat=WPKTransFaceGroup(G1,T1)
Stat= DeleteEntity(Pc)
Stat= DeleteEntity(T1)

ActivateUndo
Stat= AdvanceUndoNumber("scale face group")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_group

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