
! script name: points.d/contourmaxmin
! topic: approximate max min points on a contour.

!A
!A NAME:
!A
!A 	Contour Max Min Points
!A
!A DESCRIPTION:
!A
!A      This script creates two points which are the max min limits
!A      of the contour. This is an exact value for lines,circles,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
!A~ image location - images/maxminpoint.jpg
!B INSTRUCTIONS:
!B
!B 	PICK  CONTOUR: Pick an element on the contour.
!B

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

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


ActivateUndo
Pick_loop:!
Stat= SetInputFormat("n4","")
Contour=PickGroupEnt("PICK CONTOUR ")
IF (ExitScript(Destination$)) THEN Leave

Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)

L1= ContourMaxMin(Contour)
P1= ParameterPt(L1,0.0)
P2= ParameterPt(L1,1.0)

Stat=DeleteEntity(L1)

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

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

