<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Place table using existing table style template (VB.net) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5704212#M39462</link>
    <description>&lt;P&gt;I'm trying to place a table using an existing table style that has 26 rows and 7 columns with the column header text defined. When I manually place a new table using that style it is placed as designed. Trying to place a new table using that style using the Sub below I don't get any of the formatting. It places a 1x1 table. Checking the proprties of the 1x1 table it lists the correct table style.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Sub PlaceTableTemplate(ByVal tsName As String)
        Dim doc As Document
        Dim db As Database

        doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        db = doc.Database


        Dim tsID As ObjectId

        Using tr As Transaction = db.TransactionManager.StartTransaction
            Dim stDict As DBDictionary = tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead)
            If stDict.Contains(tsName) Then
                tsID = stDict.GetAt(tsName)
            Else
                MsgBox("Table style not found")
                Exit Sub
            End If
        End Using

        Dim ed As Editor
        Dim pr As PromptPointResult
        Dim tb As New Table

        ed = doc.Editor
        pr = ed.GetPoint(vbCrLf &amp;amp; "Enter table insertion point: ")
        If pr.Status = PromptStatus.OK Then
            With tb
                .TableStyle = tsID
                .Position = pr.Value
            End With
        Else
            Exit Sub
        End If

        tb.GenerateLayout()

        Using tr As Transaction = doc.TransactionManager.StartTransaction
            Dim bt As BlockTable = tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead)
            Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            btr.AppendEntity(tb)
            tr.AddNewlyCreatedDBObject(tb, True)
            tr.Commit()
        End Using
    End Sub&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Jul 2015 19:32:22 GMT</pubDate>
    <dc:creator>RodWing</dc:creator>
    <dc:date>2015-07-02T19:32:22Z</dc:date>
    <item>
      <title>Place table using existing table style template (VB.net)</title>
      <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5704212#M39462</link>
      <description>&lt;P&gt;I'm trying to place a table using an existing table style that has 26 rows and 7 columns with the column header text defined. When I manually place a new table using that style it is placed as designed. Trying to place a new table using that style using the Sub below I don't get any of the formatting. It places a 1x1 table. Checking the proprties of the 1x1 table it lists the correct table style.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; Sub PlaceTableTemplate(ByVal tsName As String)
        Dim doc As Document
        Dim db As Database

        doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        db = doc.Database


        Dim tsID As ObjectId

        Using tr As Transaction = db.TransactionManager.StartTransaction
            Dim stDict As DBDictionary = tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead)
            If stDict.Contains(tsName) Then
                tsID = stDict.GetAt(tsName)
            Else
                MsgBox("Table style not found")
                Exit Sub
            End If
        End Using

        Dim ed As Editor
        Dim pr As PromptPointResult
        Dim tb As New Table

        ed = doc.Editor
        pr = ed.GetPoint(vbCrLf &amp;amp; "Enter table insertion point: ")
        If pr.Status = PromptStatus.OK Then
            With tb
                .TableStyle = tsID
                .Position = pr.Value
            End With
        Else
            Exit Sub
        End If

        tb.GenerateLayout()

        Using tr As Transaction = doc.TransactionManager.StartTransaction
            Dim bt As BlockTable = tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead)
            Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            btr.AppendEntity(tb)
            tr.AddNewlyCreatedDBObject(tb, True)
            tr.Commit()
        End Using
    End Sub&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jul 2015 19:32:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5704212#M39462</guid>
      <dc:creator>RodWing</dc:creator>
      <dc:date>2015-07-02T19:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Place table using existing table style template (VB.net)</title>
      <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708073#M39463</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the second transaction?, just delete the second transaction and commit the first transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 01:08:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708073#M39463</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2015-07-07T01:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Place table using existing table style template (VB.net)</title>
      <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708637#M39464</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/587082"&gt;@hgasty1001&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why the second transaction?, just delete the second transaction and commit the first transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Gaston, Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason for the second transaction is that I actually have this broken apart in separate classes. I combined the code from the different functions to create this sub to more easily illustrate what I'm trying to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 12:57:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708637#M39464</guid>
      <dc:creator>RodWing</dc:creator>
      <dc:date>2015-07-07T12:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Place table using existing table style template (VB.net)</title>
      <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708704#M39465</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then, &amp;nbsp;you have to commit the first transaction too. I use this to create a table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.-Start a transaction&lt;/P&gt;&lt;P&gt;2.-Instance a new table&lt;/P&gt;&lt;P&gt;3.-Asign style and properties&lt;/P&gt;&lt;P&gt;4.-Generate layout&lt;/P&gt;&lt;P&gt;5.-Add to DB&lt;/P&gt;&lt;P&gt;6.-Commit the transaction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 13:26:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708704#M39465</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2015-07-07T13:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Place table using existing table style template (VB.net)</title>
      <link>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708874#M39466</link>
      <description>&lt;P&gt;Gaston,&lt;BR /&gt;I'll assume you assign the Styles (3.) separately to all the parts of the Instantiated table as i do.&lt;BR /&gt;In earlier experiments assigning the StyleId to the table didn't work for me either.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 14:46:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/place-table-using-existing-table-style-template-vb-net/m-p/5708874#M39466</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-07-07T14:46:06Z</dc:date>
    </item>
  </channel>
</rss>

