
! script name: parasolids.d/pkbodycentroid
! solids: find the center of gravity of a solid body

!A
!A NAME:
!A
!A 	Body Centroid
!A
!A DESCRIPTION:
!A
!A 	This script finds the centroid of a solid body.
!A 	The centroid is the center of gravity of the body, assuming
!A 	constant density.
!A
!# see also - htdocs/help.d/parasolids.htm

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

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

ActivateUndo

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

P1= WPKBodyCentroid(Pkbody)


ActivateUndo
Stat= AdvanceUndoNumber("body centroid")
Stat= AddItemToUndo(WsUBCreateMode,P1)

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