
! script name: vpksolids.d/vpkthickensurf
! var_solids: thicken a sheet body

!A
!A NAME:
!A
!A 	Thicken Sheet  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script will thicken a sheet body. It will apply an offset
!A	in the forward and reverse normal directions to the sheet.
!A
!B~ image location - images/pkthickensheet.gif
!B
!B INSTRUCTIONS:
!B
!B 	PICK SHEET BODY: Pick the parasolid sheet body to be thickened.
!B
!B 	FORWARD NORMAL OFFSET: Enter the thickness applied in the forward
!B 		normal direction.
!B
!B 	REVERSE NORMAL OFFSET: Enter the thickness applied in the reverse
!B 		normal direction.
!B
!B NOTE:
!B
!B 	Not every sheet body can be thickened. In general parasolids can
!B 	thicken sheets when the offset is less than the local curvature
!B 	of the surfaces involved. It seems to handle sharp corners very well.
!B 	It can fail if the offset is great enough to elimimate faces.
!B
!# see also - htdocs/help.d/parasolids.htm

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

DIM Destination$[256]
DIM Answer$[256]
DIM Body$[256]
DIM Forward_var$[256]
DIM Reverse_var$[256]


ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Stat= GLPlotOn

Ploop:!

E1=WPKPickEntity("PICK SHEET BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Ploop

Body= WPKParentBody(E1)
Body_type= WPKBodyType(Body)
IF Body_type<> WsPKSheetBody THEN Ploop
Stat= EntityNameCheck(Body,Body$)

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Offset1)
Offset1=InputDepth("FORWARD NORMAL OFFSET")
IF ExitScript(Destination$) THEN Leave
No_forward_var= LastVariableInput(Forward_var$)

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Offset2)
Offset2=InputDepth("REVERSE NORMAL OFFSET")
IF ExitScript(Destination$) THEN Leave
No_reverse_var= LastVariableInput(Reverse_var$)


WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("SOLIDS: thicken sheet")
IF No_forward_var THEN
        V1= FreeParameter("Forward normal offset",Offset1)
ELSE
        V1= FreeParameter("Forward normal offset",Forward_var$)
END IF
IF No_reverse_var THEN
        V2= FreeParameter("Reverse normal offset",Offset2)
ELSE
        V2= FreeParameter("Reverse normal offset",Reverse_var$)
END IF
E1= WPKThickenSheet(Body$,V1,V2)
Stat= WPKNameBody(E1,Body$)
Stat= WPKSetBodyParent(E1,1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("thicken sheet")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck

GOTO Ploop

Leave:!
LowerColorBox
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
