
! script name: vpksolids.d/vpkthickenface
! var_solids: thicken a face and unite with a solid body.

!A
!A NAME:
!A
!A 	Thicken Face  VARIATIONAL
!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 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]
DIM Body$[256]
DIM Face$[256]
DIM Name$[256]
DIM Offset_var$[256]


ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
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
No_offset_var= LastVariableInput(Offset_var$)



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


Body_type= WPKBodyType(Face$)
Body$= WPKBodyName(Face$)
IF Body_type= WsPKSheetBody THEN
	Stat= GenerateVarName("Body",Name$)
END IF

WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("SOLIDS: Thicken face")
IF No_offset_var THEN
        V1= FreeParameter("Normal offset",Offset)
ELSE
        V1= FreeParameter("Normal offset",Offset_var$)
END IF
PlotOff
E3= WPKCopyFace(Face$)
E4= WPKThickenSheet(E3,V1,0.0)
PlotOn
IF Body_type= WsPKSolidBody THEN
   G1= WPKUniteBodies(Body$,E4)
   Stat= WPKNameBodyGroup(G1,Body$)
   Stat= WPKSetBodyParent(G1,1)
   Stat= DeleteEntity(G1)
ELSE
   Stat= WPKNameBody(E4,Name$)
   Stat= WPKSetBodyParent(E4,0)
END IF
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("thicken face")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Ploop

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