
! script name: lines.d/tanperpline
! topic: construct line tangent to element perpendicular to a line

!A
!A NAME:
!A
!A 	Line Tangent To Element Perpendicular to a Line.
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line tangent to an element perpendicular
!A 	to a line.
!A
!A~ image location - images/tanperpline.gif
!A
!B INSTRUCTIONS:
!B
!B 	PICK TANGENT ELEMENT: Pick the entity that will be tangent
!B 		to the line constructed.
!B
!B 	PICK PERPENDICULAR LINE: Pick Perpendicular Line
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: tamgent to element, perp line  ")

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

DEG
Line_length= 0

ActivateUndo
Ploop:!
Stat=DynLabel("Length:"&VAL$(Line_length))
stat= SetInputFormat("n4","")
E1=PickEntity("PICK TANGENT ELEMENT ")
IF (ExitScript(Destination$)) THEN Leave
Pt=LastPickPoint

Line1=PickSpecificEnt("PICK PERPENDICULAR LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave

Angle= LineAngle(Line1)
Angle= Angle+ 90

Line_length= DynBufferValue(0,Line_length)
IF Line_length=0 THEN
	Ln1=SelectTanAngle(E1,Angle,Pt,WsUnTrimmed,GetDefault(WsLineLength))
ELSE
	Ln1=SelectTanAngle(E1,Angle,Pt,WsTrimFirst,Line_length)
END IF

Stat=DeleteEntity(Pt)
ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,Ln1)
GOTO Ploop

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