
! script name: parasolids.d/bodyoutline
! solids: generate the outline contour for a body.

!A
!A NAME:
!A
!A 	Body Outline
!A
!A DESCRIPTION:
!A
!A 	This script generates the outline of a body.
!A
!A~ image location - images/pkbodyoutline.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK BODY: Pick the body.
!B
!B 	Z LEVEL OF OUTLINE CURVE: Give the Z coordinate for the placement of
!B 		the outline curve.
!B
!C NOTE:
!C
!C	This is a new feature added in Parasolids Release 12.1. It still
!C	has some problems in that it sometimes fails to create the
!C	outline.
!C
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: solid body outline")

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


IF ARGC<2 THEN
 	Project_outline= WsTrue
ELSE
 	Project_outline= VAL(ARGV(1))
END IF


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


Zlevel:!
IF Project_outline= WsTrue THEN
	stat= SetInputFormat("n4=","")
	Stat= SetEqualsValue(Zlevel)
	Stat=SetPickReturn(WsGeometryZ)
	Zlevel=GetValue("Z LEVEL OF OUTLINE CURVE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	Stat=SetPickReturn(WsGeometryEnd)
END IF

WPKClearErrorFlag
Group= WPKBodyOutline(Pkbody,Zlevel,Project_outline)
Stat= PlotEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("body outline")
Stat= AddGroupToUndo(WsUBCreateMode,Group,0,WsTrue)
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
Stat= DeleteEntity(Group)

GOTO Start

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