
! script name: vpksolids.d/vpkoffsetbody
! var_solids: offset a sheet or solid body

!A
!A NAME:
!A
!A 	Offset Body   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script offsets a sheet or solid body.
!A
!A~ image location - images/pkoffsetbody.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY: Pick the body
!B
!B 	NORMAL OFFSET: Enter the offset + outside, - inside.
!B
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: offset body ")

DIM Destination$[256]
DIM Answer$[256]
DIM Body$[256]
DIM Offset_var$[256]


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

Stat= GLPlotOn
Pick_body:!
Pkbody= WPKCurrentBody
IF NOT WPKIsEntity(Pkbody) THEN
        Stat=SetInputFormat("n4","")
        E1=WPKPickEntity("PICK BODY")
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT WPKIsEntity(E1) THEN Pick_body
        Pkbody= WPKParentBody(E1)
END IF
Stat= EntityNameCheck(Pkbody,Body$)

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Offset)
Offset=InputDepth("NORMAL OFFSET")
IF ExitScript(Destination$) THEN Leave
No_offset_var= LastVariableInput(Offset_var$)

WPKClearErrorFlag
RecordFunctionOn
Stat= RecordDescr("BODY: offset body")
IF No_offset_var THEN
        V1= FreeParameter("Normal offset",Offset)
ELSE
        V1= FreeParameter("Normal offset",Offset_var$)
END IF
Pkbody= WPKOffsetBody(Body$,V1)
Stat= WPKNameBody(Pkbody,Body$)
Stat= WPKSetBodyParent(Pkbody,1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("offset body")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck

GOTO Pick_body

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