
! script name: 3dintersect.d/surflimitpts
! 3dtopic: limit points for a 3D surface 

!A
!A NAME:
!A
!A 	3D Surface limit points
!A
!A DESCRIPTION:
!A
!A 	This script makes two points from a surface.
!A	One point is at xmin,ymin,zmin of the surface
!A	The other  point is at xmax,ymax,zmax of the surface
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE: Pick the surface.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: surface limit points ")

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

ActivateUndo
Tol=NamedVarVal("3D Part Limits Tol",Ws3DSystemVars,0.040)

Start:!

Pick_loop:!

Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n4","")
Surface=PickEntity("PICK SURFACE ")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Surface) THEN Pick_loop

L1=SurfMaxMinLimits(Surface,Tol)
IF NOT ValidGeometry(L1) THEN Pick_loop

Ps= ParameterPt(L1,0.0)
Pe= ParameterPt(L1,1.0)
Stat= DeleteEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("limit points")
Stat= AddItemToUndo(WsUBCreateMode,Ps)
Stat= AddItemToUndo(WsUBCreateMode,Pe)

GOTO Start


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