TheSwamp

Code Red => .NET => Topic started by: gvgbabu on August 29, 2014, 04:27:04 AM

Title: table is not visible in the drawing when i reopen or print
Post by: gvgbabu on August 29, 2014, 04:27:04 AM
hi

i have created a table using vb.net 2005. it inserts table as external reference. i could not explode or visible the table when i print or reopen.  how to insert explodable or modificable table using vb.net 2005. i am here attached the drawing. how to use table.explode command in vb.net 2005.

please guide me
thanks in advance
gvg
Title: Re: table is not visible in the drawing when i reopen or print
Post by: Bert on August 29, 2014, 10:57:30 AM
Hello babu,

The drawing you included was "empty".

From your question I understand that you wish to insert an AutoCAD table into your modelspace ?
There this article you could read : http://through-the-interface.typepad.com/through_the_interface/2007/06/creating_an_aut.html (http://through-the-interface.typepad.com/through_the_interface/2007/06/creating_an_aut.html)
This example has C# code.
In VB it should look something like this :
Code: [Select]
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor

Dim pr As PromptPointResult = ed.GetPoint(vbLf & "Enter table insertion point: ")
If pr.Status = PromptStatus.OK Then
Dim tb As New Table()
tb.TableStyle = db.Tablestyle
tb.NumRows = 5
tb.NumColumns = 3
tb.SetRowHeight(3)
tb.SetColumnWidth(15)
tb.Position = pr.Value

' Create a 2-dimensional array
' of our table contents
Dim str As String(,) = New String(4, 2) {}
str(0, 0) = "Part No."
str(0, 1) = "Name "
str(0, 2) = "Material "
str(1, 0) = "1876-1"
str(1, 1) = "Flange"
str(1, 2) = "Perspex"
str(2, 0) = "0985-4"
str(2, 1) = "Bolt"
str(2, 2) = "Steel"
str(3, 0) = "3476-K"
str(3, 1) = "Tile"
str(3, 2) = "Ceramic"
str(4, 0) = "8734-3"
str(4, 1) = "Kean"
str(4, 2) = "Mostly water"

' Use a nested loop to add and format each cell
For i As Integer = 0 To 4
For j As Integer = 0 To 2
tb.SetTextHeight(i, j, 1)
tb.SetTextString(i, j, str(i, j))
tb.SetAlignment(i, j, CellAlignment.MiddleCenter)
Next
Next
tb.GenerateLayout()

Dim tr As Transaction = doc.TransactionManager.StartTransaction()
Using tr
Dim bt As BlockTable = DirectCast(tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
btr.AppendEntity(tb)
tr.AddNewlyCreatedDBObject(tb, True)
tr.Commit()
End Using
End If
Title: Re: table is not visible in the drawing when i reopen or print
Post by: gvgbabu on August 29, 2014, 11:58:54 AM
Hi Bert thanks for your reply. The drawing is not empty. when you select all/List/p it shows ACAD_TABLE. I also used the same code as you suggested to insert a table.
Now i got some thing that when i right click on the table and select update table in autocad 2007 then it's visible, explodable and modificable. i didnt get any information on update table. let me know what is that property. how can we include that property in vb.net.
Title: Re: table is not visible in the drawing when i reopen or print
Post by: Bert on September 01, 2014, 03:28:17 AM
Hello babu,

Quoting the reference guide; After creating a new Table object using the constructor, you usually need to set the table style, number of rows and columns, column width, row height, insert position, width direction, and normal vector. You can also enter text or block contents into each cell using Table methods.

I'm not aware of an actual "update" method, nor does the documentation speak of one.

Just edit the table and maybe do a 'regen', this will most certainly 'update' your table.