Table height problem - how to insert Table by choosing it's bottom-right corner?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
I have to make it possible to insert table by choosing any of it's corners. I cannot get it to work with choosing bottom corners - I can't get the exact height of the table.
The sample code of the one-row table is:
acApp.Document doc = acApp.Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Transaction tr = ed.Document.Database.TransactionManager.StartTransaction(); try { BlockTable bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead); Table tb = new Table(); tb.InsertColumns(0, 24, 1); tb.SetRowHeight(4); tb.Columns[0].Width = 24; tb.Columns[1].Width = 24; tb.Cells[0, 0].TextHeight = 2; tb.Cells[0, 0].TextString = "some text"; tb.Cells[0, 0].Alignment = CellAlignment.MiddleRight; tb.Cells[0, 1].TextHeight = 2; tb.Cells[0, 1].TextString = other_text_from_variable; tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter; tb.HorizontalCellMargin = 0; tb.VerticalCellMargin = 0; tb.GenerateLayout(); tb.Position = // exactly... what should I do here? BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); btr.AppendEntity(tb); tr.AddNewlyCreatedDBObject(tb, true); tr.Commit(); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { ed.WriteMessage("\n ERR: " + ex.Message); } finally { tr.Dispose(); }
Now... I'm trying to make 1-row table width the height 4. I should set tb.Position by just subtracting 4 from the Y-value of the clicked point... NOT.
tb.Height gives me 4. But I get the table with height 5.667. And I can't just use that value for subtracting, because even then, bottom-right corner is about 0.2 above or below clicked point... (X-value is correct and equals the clicked point's X-value.)
The same thing happens when I insert a table with the number of rows depending on the number of the records selected from DB. The same thing happens, when I use obsolete .NumRows and .NumColumns. What am I missing?