
! script name: points.d/boxmaxmin
! topic: approximate max min points on geometry in a box.

!A
!A NAME:
!A
!A 	Box Max Min Points
!A
!A DESCRIPTION:
!A
!A 	Approximate max min points on geometry in a box.
!A      This script creates two points which are the max min limits of the
!A 	contour.  This is an exact value for lines, circles, and ellipses.
!A	It is an approximate value for cubic splines, bspline or nurb curves,
!A	as well as helii. The max min points are calculated relative to 
!A	the current workplane.
!A

stat=ChangeLabelStr("ScriptNameStatus","Function: box max min ")

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

ActivateUndo
Pick_loop:!

Group=CreateGroup("TEMPGROUP")

Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF (ExitScript(Destination$)) THEN Leave

Stat=PickBox(Group,Vnum,12)
IF (ExitScript(Destination$)) THEN Leave

Stat=Highlight(Group,WsPickPen,WsDirArrowOff)

L1= GroupMaxMin(Group)
P1= ParameterPt(L1,0.0)
P2= ParameterPt(L1,1.0)

Stat=DeleteEntity(L1)
Stat=DeleteEntity(Group)
ActivateUndo
Stat= AdvanceUndoNumber("point")
Stat= AddItemToUndo(WsUBCreateMode,P2)
Stat= AddItemToUndo(WsUBCreateMode,P1)
GOTO Pick_loop

Leave:!
Stat=DeleteEntity(L1)
Stat=DeleteEntity(Group)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

