
! script name: tableinsert.d/tangltwolines
! topic: insert the angle between two lines into a table

!A
!A NAME:
!A
!A 	Table: Info: Angle Two Lines
!A
!A DESCRIPTION:
!A
!A 	This script will insert the angle between two picked lines into a
!A 	position selected in a table.
!A
!B INSTRUCTIONS:
!B
!B 	STARTING LINE: Pick the starting line to be used for the angle between
!B 		two lines.
!B
!B 	ENDING LINE: Pick the ending line to be used for the angle between
!B 		two lines.
!B
!B 	PICK ENTRY POSITION: Pick the position in the table for the angle
!B 		between the two picked lines to be entered.
!B
!B NOTES:
!B
!B 	This script is not variational. The table will not update
!B 	when the entity in changed.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: Angle into table")

DIM Answer$[256]
DIM Descr$[256]
DIM Destination$[256]
DIM Format$[15]
DEG

A= GetDefault(WsAPlacesAfter)
Format$= "degrees "&VAL$(A)

Start:!
ActivateUndo

stat= SetInputFormat("n4","")
Pick_start:E1=PickSpecificEnt("STARTING LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Pick_start

Pick_end:!
E2=PickSpecificEnt("ENDING LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E2) THEN Pick_end


Pick_entry:!
stat= SetInputFormat("n4","")
Table1=PickEntity("PICK ENTRY POSITION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Table1) THEN Pick_entry
T1= LastPickPara
R1=TableParaRow(Table1,T1)
C1=TableParaColumn(Table1,T1)

ActivateUndo
Stat= AdvanceUndoNumber("angle entry")
Stat= AddItemToUndo(WsUBModifyMode,Table1)

Stat= EraseEntity(Table1)
Stat= InsertIntoTable(Table1,AngleTwoLines(E1,E2),Format$,R1,C1)
Stat= TableTextOrigin(Table1,R1,C1,WsRightCenter)
Stat= PlotEntity(Table1)

GOTO Start


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