<?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 Re: block id is not null but block will not insert in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4330962#M48766</link>
    <description>&lt;P&gt;We really need to see more of your code to help, but from what you did post, i would say you need a transaction, here's a little block insertion&amp;nbsp;snippet for reference:&lt;/P&gt;&lt;PRE&gt; Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim id As ObjectId = bt("YourBlockNameHere")
                Dim ppo As New PromptPointOptions(vbCrLf &amp;amp; "Specify insertion point:")
                Dim ppr As PromptPointResult = ed.GetPoint(ppo)
                If ppr.Status = PromptStatus.OK Then
                    Dim pts As Point3d = ppr.Value
                    Dim br As New BlockReference(pts, id)
                    Dim btr As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                    btr.AppendEntity(br)
                    tr.AddNewlyCreatedDBObject(br, True)
                    tr.Commit()
                End If
            End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2013 22:30:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-07-15T22:30:25Z</dc:date>
    <item>
      <title>block id is not null but block will not insert</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4326236#M48764</link>
      <description>&lt;P&gt;I am trying to insert a block that already exists in the drawing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting a value for the block id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a msg box to post&lt;/P&gt;&lt;P&gt;However, when I try to insert the block&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting an error that says the block id is null&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;blkbl = blktbul(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)&lt;BR /&gt;MsgBox(blkrec.Name)&lt;/P&gt;&lt;P&gt;tblkid2 = blkrec.ObjectId&lt;BR /&gt;MsgBox(tblkid2.ToString &amp;amp; " tblkid2" &amp;amp; tblkid3.ToString)&lt;BR /&gt;blktbul.UpgradeOpen()&lt;BR /&gt;' blokrec = blktrnz.GetObject(lytbtbl.Item("blknm"), OpenMode.ForWrite)&lt;BR /&gt;&lt;STRONG&gt;tblkin = New BlockReference(inspnt, blkrec.ObjectId)&lt;/STRONG&gt;&lt;BR /&gt;MsgBox(tblkin.BlockName.ToString)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2013 21:55:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4326236#M48764</guid>
      <dc:creator>Bauron</dc:creator>
      <dc:date>2013-07-10T21:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: block id is not null but block will not insert</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4327246#M48765</link>
      <description>&lt;P&gt;I cannot see from here, but make sure the blkrec.ObjectId is really a BlockTableRecord, but not the Model or Paper space.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2013 16:54:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4327246#M48765</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2013-07-11T16:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: block id is not null but block will not insert</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4330962#M48766</link>
      <description>&lt;P&gt;We really need to see more of your code to help, but from what you did post, i would say you need a transaction, here's a little block insertion&amp;nbsp;snippet for reference:&lt;/P&gt;&lt;PRE&gt; Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                Dim id As ObjectId = bt("YourBlockNameHere")
                Dim ppo As New PromptPointOptions(vbCrLf &amp;amp; "Specify insertion point:")
                Dim ppr As PromptPointResult = ed.GetPoint(ppo)
                If ppr.Status = PromptStatus.OK Then
                    Dim pts As Point3d = ppr.Value
                    Dim br As New BlockReference(pts, id)
                    Dim btr As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                    btr.AppendEntity(br)
                    tr.AddNewlyCreatedDBObject(br, True)
                    tr.Commit()
                End If
            End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2013 22:30:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-id-is-not-null-but-block-will-not-insert/m-p/4330962#M48766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-15T22:30:25Z</dc:date>
    </item>
  </channel>
</rss>

