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

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

stat=ChangeLabelStr("ScriptNameStatus","Function: x 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,1)
	P2= WPKExtremePoint(Pkgroup,4)

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

Body_extreme:!
Pkbody= WPKParentBody(E1)
P1= WPKExtremePoint(Pkbody,1)
P2= WPKExtremePoint(Pkbody,4)

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