
! script name: lines.d/perpendicular
! topic: construct perpendicular line through point

!A
!A NAME:
!A
!A 	Perpendicular Line
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line through a point perpendicular to a line.
!A
!A~ image location - images/perpendicular.jpg
!B INSTRUCTIONS:
!B
!B 	PICK PERPENDICULAR LINE: Pick the line that will be used to construct
!B 		a line perpendicular to it.
!B
!B 	INPUT ABS X,Y: Enter the X,Y coordinates of the point through which
!B 		the perpendicular line will be constructed.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

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

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

DEG

ActivateUndo
Line_loop:!
stat= SetInputFormat("n4","")
E1=PickSpecificEnt("PICK PERPENDICULAR LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Line_loop

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

L1=Perpendicular(E1,Pt,WsUNTRIMMED)

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

