
! script name: pktransform.d/pkmoveface
! solids: move a face within a body

!A
!A NAME:
!A
!A 	Move a Face within a Body
!A
!A DESCRIPTION:
!A
!A 	This script will move a face within a body.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FACE 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 face may be moved within a body provided the
!C      intersections with the neighboring elements are simple enough.
!C      The moved face must basically intersect the same faces that
!C      it did before the move. Faces cannot be eliminated, the moved
!C      face 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")

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

ActivateUndo

Stat= GLPlotOn
Pick_face:!
E1=WPKPickEntity("PICK FACE TO BE MOVED",WsPKPickFace)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Pick_face

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=WPKTransformFace(E1,T4)
Stat= DeleteEntityList(Ps,Pe,T1,T2,T3,T4)

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

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
