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

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

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

DIM Destination$[256]
DIM Answer$[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,2)
        P2= WPKExtremePoint(Pkgroup,5)

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


Body_extreme:!
Pkbody= WPKParentBody(E1)
P1= WPKExtremePoint(Pkbody,2)
P2= WPKExtremePoint(Pkbody,5)



Record_undo:!
ActivateUndo
Stat= AdvanceUndoNumber("y 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
