
! script name: pkgroups.d/pkmovegroup
! solids: move a group of faces within a body

!A
!A NAME:
!A
!A 	Move Face Group
!A
!A DESCRIPTION:
!A
!A 	This script will move a group of faces within a body.
!A
!A~ image location - images/pkmovefacegrp.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK GROUP TO BE MOVED: Pick the group.
!B
!B 	REFERENCE POINT: Input the reference point.
!B
!B 	DESTINATION POINT: Input the destination point.
!B
!C NOTES:
!C
!C	A group of faces may be moved within a body provided the
!C	intersections with the neighboring elements are simple enough.
!C	The moved faces must basically intersect the same faces that
!C	they did before the move. Faces cannot be eliminated, the moved
!C	faces cannot separate the body into multiple bodies. More things
!C	are possible with analytic surfaces than with non-analytic
!C	surfaces such as nurbs.
!C
!# see also - htdocs/help.d/parasolids.htm

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

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

ActivateUndo

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

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

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

T1=AngleTransform(Ps,0,0,0,WsWorkplaneVals)
T2= InverseTrans(T1)
T3=AngleTransform(Pe,0.0,0.0,0.0,WsWorkplaneVals)
T4= MultTransforms(T3,T2)

WPKClearErrorFlag
Stat=WPKTransFaceGroup(G1,T4)
Stat= DeleteEntityList(Ps,Pe,T1,T2,T3,T4)

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

Leave:!
Stat= DeleteEntityList(Ps,Pe,T1,T2,T3,T4)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
