
! script name: lines.d/normalline
! topic: construct line normal to existing element

!A
!A NAME:
!A
!A 	Normal Line
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line normal to an existing element.
!A
!B INSTRUCTIONS:
!B
!B 	PICK NORMAL ELEMENT: Pick the element that will be the
!B 		reference for the normal line.
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of the point,
!B 		through which the line normal to the entity will be constructed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: normal line ")

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

DEG

ActivateUndo
Line_loop:!
stat= SetInputFormat("n4","")
E1=PickEntity("PICK NORMAL ELEMENT")
IF (ExitScript(Destination$)) THEN Leave

Pt=XyzInput("INPUT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Line_loop

L1=NormalLine(E1,Pt,WsTRIMMED)

Stat=DeleteEntity(Pt)
ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L1)
GOTO Line_loop

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