
! script name: parasolids.d/pkbodytype
! solids: interrogate the type of a body

!A
!A NAME:
!A
!A 	Body Type
!A
!A DESCRIPTION:
!A
!A 	This script gives the type of a body.
!A	The body types are WIRE BODY,SHEET BODY,SOLID BODY, and GENERAL BODY.
!A
!A
!# see also - htdocs/help.d/parasolids.htm

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

DIM Destination$[256]
DIM Answer$[256]
DIM File$[256]
DIM A$[32000]
DIM B$[32000]
DIM Title$[256]
DIM Name$[256]
DIM Label$[256]

ActivateUndo
Title$= "EXTREME DATA"
File$= "tempdata"
Stat= RemoveFile(File$)

Start:!
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

body_type= WPKBodyType(Pkbody)
SELECT body_type
CASE WsPKSolidBody
	Btype$= "SOLID BODY"
CASE WsPKSheetBody
	Btype$= "SHEET BODY"
CASE WsPKWireBody
	Btype$= "WIRE BODY"
CASE ELSE
	Btype$= "GENERAL BODY"
END SELECT

Label$= "BODY TYPE"
Stat= OutputString(File$,Label$&CHR$(10),WsNewFile)
stat= OutputString(File$,Btype$&CHR$(10),WsAppend)
OUTPUT A$ USING "17A,9D";"PARASOLID TAG #: ",WPKEntityTag(Pkbody)
stat= OutputString(File$,A$&CHR$(10),WsAppend)
Stat=MessageFileBox(File$,Title$)

Num1= WPKBodiesCount
IF Num1 > 1 THEN Start

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