
! script name: parasolids.d/pkzextreme
! solids: find the z axis extreme pts on a solid body

!A
!A NAME:
!A
!A 	Z Axis Extreme Points
!A
!A DESCRIPTION:
!A
!A 	This script finds the Z axis extreme points on a parasolid body
!A 	This is two points on the body which are at the Zmax and Zmin
!A 	positions on the body.	
!A
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: z axis extreme points ")

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

ActivateUndo
Start:!
Stat=SetInputFormat("a1",",G,")
E1=WPKPickEntity("PICK BODY,  Group ",WsPKPickAll,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="G" THEN
Pick_group:!
        Stat=SetInputFormat("a1",",B,")
        E1=WPKPickEntity("PICK GROUP,  Body ",WsPKPickAll,Answer$)
        IF (ExitScript(Destination$)) THEN Leave
        IF Answer$="B" THEN Start
        IF NOT WPKIsEntity(E1) THEN Pick_loop

        Pkgroup= WPKContainingGroup(E1,1)
        IF NOT WPKIsEntity(Pkgroup) THEN Pick_group

        P1= WPKExtremePoint(Pkgroup,3)
        P2= WPKExtremePoint(Pkgroup,6)

        GOTO Record_undo
END IF
IF NOT WPKIsEntity(E1) THEN Pick_loop


Body_extreme:!
Pkbody= WPKParentBody(E1)
P1= WPKExtremePoint(Pkbody,3)
P2= WPKExtremePoint(Pkbody,6)


Record_undo:!
ActivateUndo
Stat= AdvanceUndoNumber("z axis extreme pts")
Stat= AddItemToUndo(WsUBCreateMode,P1)
Stat= AddItemToUndo(WsUBCreateMode,P2)
GOTO Start

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