
! script name: points.d/nearestpt
! topic: create point nearest to the cursor on entity

!A
!A NAME:
!A
!A 	Nearest
!A
!A DESCRIPTION:
!A
!A 	This script will create a point nearest to the cursor on the entity.
!A
!B INSTRUCTIONS:
!B
!B 	PICK NEAREST ELEMENT: Pick the entity that the point should be
!B 		created on nearest to the cursor.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: nearest ")

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


DEG

ActivateUndo
Stat=SetXyzInput(WsNearest)
Ploop:Pt=XyzInput("INPUT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave

Stat=SetLastPoint(Pt,WsXyzInput)

ActivateUndo
Stat= AdvanceUndoNumber("point")
Stat= AddItemToUndo(WsUBCreateMode,Pt)
GOTO Ploop

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