
! script name: pksurfaces.d/pkthickenface
! solids: thicken a face and unite with a solid body.

!A
!A NAME:
!A
!A 	Thicken Face
!A
!A DESCRIPTION:
!A
!A	This script will thicken a face on a body.
!A
!A~ image location - images/pkthickenface.gif
!A
!B INSTRUCTIONS:
!B
!B	PICK FACE: Pick the parasolid face to be thickened.
!B
!B	NORMAL OFFSET: Enter the thickness
!B 		applied in the forward normal direction.
!B
!C NOTES:
!C
!C	Not every face can be thickened. In general parasolids can
!C	thicken faces when the offset is less than the local curvature
!C	of the surfaces involved. It seems to handle sharp corners very well.
!C	It can to fail if the offset is great enough to elimimate faces.
!C
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: thicken a face ")

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


ActivateUndo
Stat= GLPlotOn

Start:!
Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Offset)
Offset=InputDepth("NORMAL OFFSET")
IF ExitScript(Destination$) THEN Leave
IF ABS(Offset)= 0.0 THEN Start


Ploop:!
Stat=SetInputFormat("n4","")
E1=WPKPickEntity("PICK FACE",WsPKPickFace)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Face_loop

WPKClearErrorFlag
Body1= WPKParentBody(E1)
Body_type= WPKBodyType(Body1)
PlotOff
E2= WPKCopyFace(E1)
E3= WPKThickenSheet(E2,Offset,0.0)
PlotOn
Body2= WPKParentBody(E3)
IF Body_type= WsPKSolidBody THEN 
	G1= WPKUniteBodies(Body1,Body2)
	Stat= DeleteEntity(G1)
ELSE
	Stat= WPKUpdateBody(Body2)
END IF

ActivateUndo
Stat= AdvanceUndoNumber("thicken face")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Ploop

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