
! script name: vpksolids.d/vpkindentface
! var_solids: indent a face and subtract from a solid body

!A
!A NAME:
!A
!A 	Indent Face  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will indent a face into a body.
!A
!A~ image location - images/pkindentface.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK FACE: Pick the parasolid face to be indented.
!B
!B 	NORMAL OFFSET: Enter the thickness applied
!B 		in the 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: indent 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$= WPKBodyName(Face$)


WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("SOLIDS: Indent 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,0.0,V1)
PlotOn
G1= WPKSubtractBodies(Body$,E4)
Stat= WPKNameBodyGroup(G1,Body$)
Stat= WPKSetBodyParent(G1,1)
Stat= DeleteEntity(G1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("indent 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
