
! script name: datatable.d/tablecorners
! topic: set table corner points

!A
!A NAME:
!A
!A 	Corners
!A
!A DESCRIPTION:
!A
!A 	This script will set the table corner points.
!A
!B INSTRUCTIONS:
!B
!B 	PICK TABLE TO BE SIZED: Pick the table
!B 		to be sized.
!B
!B 	PICK TABLE STARTING CORNER: Pick the
!B 		starting corner of the table.
!B
!B 	PICK TABLE ENDING CORNER: Pick the
!B 		ending corner of the table.
!B
!# see also - htdocs/help.d/datatables.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: set table corner points ")

DIM Answer$[256]
DIM A$[256]
DIM Destination$[256]
DIM New_line$[10]
DIM End_line$[10]
DEG


ActivateUndo
Start:!

Element_loop:!
stat= SetInputFormat("n4","")
Element1=PickEntity("PICK TABLE TO BE SIZED")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Element1) THEN Element_loop

Pick_loop:!
Vnum= LastPickView
L1=WorkplaneBox(Vnum,"PICK TABLE STARTING CORNER","PICK TABLE ENDING CORNER")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(L1) THEN Pick_loop

Len1= LineLength(L1)
IF Len1< 0.0001 THEN
        Stat= DeleteEntity(L1)
        GOTO Start
END IF

Ps= ParameterPt(L1,0)
Pe= ParameterPt(L1,1)
Stat= DeleteEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("set corners")
Stat= AddItemToUndo(WsUBModifyMode,Element1)


Stat= EraseEntity(Element1)
Stat= SetTableCorners(Element1,Ps,Pe)
Stat= PlotEntity(Element1)

Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)

GOTO Element_loop

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