
! script name: points.d/endptsinbox
! topic: Sample - find element end points in a box

!A
!A NAME:
!A	
!A	Find Element End Points in a Box
!A
!A DESCRIPTION:
!A
!A 	This script will find element end points in a box.
!A
!B INSTRUCTIONS:
!B
!B 	PICK FIRST CORNER OF PICK ZONE: Pick a corner of the box to be used.
!B
!B 	PICK SECOND CORNER OF PICK ZONE: Pick the other corner of the box.
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: end points in a box ")

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


ActivateUndo
Stat= SetInputFormat("n4","")
Pick_loop:!
Pt1=XyzInput("FIRST CORNER PT",WsXYOnly)
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Pt1)) THEN Pick_loop

Pt2=XyzInput("SECOND CORNER PT",WsXYOnly)
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Pt2)) THEN Pick_loop

Dist= DistTwoPts(Pt1,Pt2)
IF Dist< 0.0001 THEN Pick_loop

Group= EndPointsInBox(pt1,pt2,WsXyOnly)

Stat= DeleteEntity(Pt1)
Stat= DeleteEntity(Pt2)

ActivateUndo
Stat= AdvanceUndoNumber("points")
Stat= AddGroupToUndo(WsUBCreateMode,Group,WsTrue,WsFalse)


GOTO Pick_loop

Leave:!
Stat= DeleteEntity(Pt1)
Stat= DeleteEntity(Pt2)
Stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
