<?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: Insert a Wblock in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495647#M70307</link>
    <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;It's the ObjectID for the block reference in the &lt;BR /&gt;
block table record.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Joe ...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:cwhitaker@powerflame.com"&amp;gt;cwhitaker@powerflame.com&lt;/A&gt;&amp;gt; wrote &lt;BR /&gt;
  in message &lt;A&gt;&lt;BR /&gt;
  href="news:6190981@discussion.autodesk.com"&amp;gt;news:6190981@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;Thanks &lt;BR /&gt;
  for the help but i have one more question for you. I am assuming that &lt;BR /&gt;
  "workingDb" is the active document database but what is &lt;BR /&gt;
"blockdefObjId"?&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 28 May 2009 14:06:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-05-28T14:06:37Z</dc:date>
    <item>
      <title>Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495644#M70304</link>
      <description>I have found a lot of exmples on inserting blocks already defined in the drawing but i am trying to figure out how to insert a w block?</description>
      <pubDate>Wed, 27 May 2009 19:59:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495644#M70304</guid>
      <dc:creator>cwhitaker</dc:creator>
      <dc:date>2009-05-27T19:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495645#M70305</link>
      <description>cwhitaker@powerflame.com schreef:&lt;BR /&gt;
&amp;gt; I have found a lot of exmples on inserting blocks already defined in the &lt;BR /&gt;
&amp;gt; drawing but i am trying to figure out how to insert a w block?&lt;BR /&gt;
&lt;BR /&gt;
VB example:&lt;BR /&gt;
&lt;BR /&gt;
Dim dbDwg As New Database&lt;BR /&gt;
dbDwg.ReadDwgFile(blockFileName, IO.FileShare.Read, True, "")&lt;BR /&gt;
blockdefObjId = workingDb.Insert(blockName, dbDwg, True)&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://cupocadnet.blogspot.com</description>
      <pubDate>Wed, 27 May 2009 20:24:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495645#M70305</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-05-27T20:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495646#M70306</link>
      <description>Thanks for the help but i have one more question for you.&lt;BR /&gt;
&lt;BR /&gt;
I am assuming that "workingDb" is the active document database but what is "blockdefObjId"?</description>
      <pubDate>Thu, 28 May 2009 13:07:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495646#M70306</guid>
      <dc:creator>cwhitaker</dc:creator>
      <dc:date>2009-05-28T13:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495647#M70307</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;It's the ObjectID for the block reference in the &lt;BR /&gt;
block table record.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Joe ...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:cwhitaker@powerflame.com"&amp;gt;cwhitaker@powerflame.com&lt;/A&gt;&amp;gt; wrote &lt;BR /&gt;
  in message &lt;A&gt;&lt;BR /&gt;
  href="news:6190981@discussion.autodesk.com"&amp;gt;news:6190981@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;Thanks &lt;BR /&gt;
  for the help but i have one more question for you. I am assuming that &lt;BR /&gt;
  "workingDb" is the active document database but what is &lt;BR /&gt;
"blockdefObjId"?&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 May 2009 14:06:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495647#M70307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-05-28T14:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495648#M70308</link>
      <description>Here is what i came up with in case anyone else search for this problem.  The InsertBlock and SetAttributes code is from a book i bought called "VB.Net Programing for AutoCAD Customization" and i think it is a good book to learn with.&lt;BR /&gt;
&lt;BR /&gt;
Public Shared Sub ImportBlock(ByVal BlockFile As String, ByVal BlockName As String)&lt;BR /&gt;
        Dim myDwg As ApplicationServices.Document&lt;BR /&gt;
        Dim myDwgLoc As DocumentLock&lt;BR /&gt;
        Dim mySourceDB As New Database&lt;BR /&gt;
        Dim myActiveDB As Database&lt;BR /&gt;
        'Read file and load block into current database&lt;BR /&gt;
        Try&lt;BR /&gt;
            myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
            myDwgLoc = myDwg.LockDocument()&lt;BR /&gt;
            myActiveDB = myDwg.Database&lt;BR /&gt;
            mySourceDB.ReadDwgFile(BlockFile, IO.FileShare.Read, True, "")&lt;BR /&gt;
            myActiveDB.Insert(BlockName, mySourceDB, True)&lt;BR /&gt;
            mySourceDB.Dispose()&lt;BR /&gt;
            myDwgLoc.Dispose()&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
            MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error")&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
    Public Shared Function InsertBlock(ByVal InsPt As Geometry.Point3d, ByVal BlockName As String, Optional ByVal XScale As Double = 1.0, Optional ByVal YScale As Double = 1.0, Optional ByVal ZScale As Double = 1.0) As DatabaseServices.ObjectId&lt;BR /&gt;
        Try&lt;BR /&gt;
            Dim myTransMan As DatabaseServices.TransactionManager&lt;BR /&gt;
            Dim myTrans As DatabaseServices.Transaction&lt;BR /&gt;
            Dim myDwg As ApplicationServices.Document&lt;BR /&gt;
            Dim myBT As DatabaseServices.BlockTable&lt;BR /&gt;
            Dim myBTR As DatabaseServices.BlockTableRecord&lt;BR /&gt;
            Dim myAttColl As DatabaseServices.AttributeCollection&lt;BR /&gt;
            Dim myEnt As DatabaseServices.Entity&lt;BR /&gt;
            Dim myBTREnum As BlockTableRecordEnumerator&lt;BR /&gt;
            Dim myDwgLoc As DocumentLock&lt;BR /&gt;
            'Get active document and begin transaction&lt;BR /&gt;
            myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
            myDwgLoc = myDwg.LockDocument()&lt;BR /&gt;
            myTransMan = myDwg.TransactionManager&lt;BR /&gt;
            myTrans = myTransMan.StartTransaction&lt;BR /&gt;
            'Open Block Table&lt;BR /&gt;
            myBT = myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)&lt;BR /&gt;
            myBTR = myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)&lt;BR /&gt;
            'Insert the Block&lt;BR /&gt;
            Dim myBlockDef As BlockTableRecord = myBT(BlockName).GetObject(OpenMode.ForRead)&lt;BR /&gt;
            Dim myBlockRef As New DatabaseServices.BlockReference(InsPt, myBT(BlockName))&lt;BR /&gt;
            myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale)&lt;BR /&gt;
            myBTR.AppendEntity(myBlockRef)&lt;BR /&gt;
            myTrans.AddNewlyCreatedDBObject(myBlockRef, True)&lt;BR /&gt;
            'Set Attribute values&lt;BR /&gt;
            myAttColl = myBlockRef.AttributeCollection&lt;BR /&gt;
            myBTREnum = myBlockDef.GetEnumerator&lt;BR /&gt;
            While myBTREnum.MoveNext&lt;BR /&gt;
                myEnt = myBTREnum.Current.GetObject(OpenMode.ForWrite)&lt;BR /&gt;
                If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then&lt;BR /&gt;
                    Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt&lt;BR /&gt;
                    Dim myAttRef As New DatabaseServices.AttributeReference&lt;BR /&gt;
                    myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)&lt;BR /&gt;
                    myAttColl.AppendAttribute(myAttRef)&lt;BR /&gt;
                    myTrans.AddNewlyCreatedDBObject(myAttRef, True)&lt;BR /&gt;
                End If&lt;BR /&gt;
            End While&lt;BR /&gt;
            myDwgLoc.Dispose()&lt;BR /&gt;
            myTrans.Commit()&lt;BR /&gt;
            'Clean up&lt;BR /&gt;
            myTrans.Dispose()&lt;BR /&gt;
            myTransMan.Dispose()&lt;BR /&gt;
            Return myBlockRef.ObjectId&lt;BR /&gt;
        Catch e As Exception&lt;BR /&gt;
            MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error")&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
    Public Shared Sub SetAttributes(ByVal BlockId As DatabaseServices.ObjectId, ByVal TagList As Collection)&lt;BR /&gt;
        Try&lt;BR /&gt;
            Dim myTransMan As DatabaseServices.TransactionManager&lt;BR /&gt;
            Dim myTrans As DatabaseServices.Transaction&lt;BR /&gt;
            Dim myDwg As ApplicationServices.Document&lt;BR /&gt;
            Dim myDwgLoc As DocumentLock&lt;BR /&gt;
            Dim myBlkRef As DatabaseServices.BlockReference&lt;BR /&gt;
            Dim myAttColl As DatabaseServices.AttributeCollection&lt;BR /&gt;
            Dim myEnt As DatabaseServices.ObjectId&lt;BR /&gt;
            Dim myAttRef As DatabaseServices.AttributeReference&lt;BR /&gt;
&lt;BR /&gt;
            'Get active document and begin transaction&lt;BR /&gt;
            myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
            myDwgLoc = myDwg.LockDocument()&lt;BR /&gt;
            myTransMan = myDwg.TransactionManager&lt;BR /&gt;
            myTrans = myTransMan.StartTransaction&lt;BR /&gt;
            'Find block and set attributes&lt;BR /&gt;
            myBlkRef = BlockId.GetObject(OpenMode.ForWrite)&lt;BR /&gt;
            myAttColl = myBlkRef.AttributeCollection&lt;BR /&gt;
            For Each myEnt In myAttColl&lt;BR /&gt;
                myAttRef = myEnt.GetObject(OpenMode.ForWrite)&lt;BR /&gt;
                Dim myItem As String&lt;BR /&gt;
                Try&lt;BR /&gt;
                    myItem = TagList(myAttRef.Tag)&lt;BR /&gt;
                    myAttRef.TextString = myItem&lt;BR /&gt;
                Catch &lt;BR /&gt;
                End Try&lt;BR /&gt;
            Next&lt;BR /&gt;
            myDwgLoc.Dispose()&lt;BR /&gt;
            myTrans.Commit()&lt;BR /&gt;
            'Clean up&lt;BR /&gt;
            myTrans.Dispose()&lt;BR /&gt;
            myTransMan.Dispose()&lt;BR /&gt;
        Catch e As Exception&lt;BR /&gt;
            MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error")&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
&lt;BR /&gt;
Here is how you call them:&lt;BR /&gt;
Dim myBlk As DatabaseServices.ObjectId&lt;BR /&gt;
myBlk = DwgTools.InsertBlock(New Geometry.Point3d(0, 0, 0), "titlebka")&lt;BR /&gt;
Dim myTags As New Collection&lt;BR /&gt;
 myTags.Add("me", "Drawn_By")&lt;BR /&gt;
 myTags.Add("whatever", "Drawing_Number")&lt;BR /&gt;
DwgTools.SetAttributes(myBlk, myTags)&lt;BR /&gt;
DwgTools.ImportBlock("f:\autocad_dwgs\symbols\agen\supply1.dwg", "ChrisW")&lt;BR /&gt;
DwgTools.InsertBlock(New Geometry.Point3d(5, 5, 0), "chrisw")</description>
      <pubDate>Thu, 28 May 2009 14:19:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495648#M70308</guid>
      <dc:creator>cwhitaker</dc:creator>
      <dc:date>2009-05-28T14:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Insert a Wblock</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495649#M70309</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Please either post in Rich Text format or attach a &lt;BR /&gt;
text file.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2" face="Arial"&gt;Joe ...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:cwhitaker@powerflame.com"&amp;gt;cwhitaker@powerflame.com&lt;/A&gt;&amp;gt; wrote &lt;BR /&gt;
  in message &lt;A&gt;&lt;BR /&gt;
  href="news:6191059@discussion.autodesk.com"&amp;gt;news:6191059@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;Here &lt;BR /&gt;
  is what i came up with in case anyone else search for this problem. The &lt;BR /&gt;
  InsertBlock and SetAttributes code is from a book i bought called "VB.Net &lt;BR /&gt;
  Programing for AutoCAD Customization" and i think it is a good book to learn &lt;BR /&gt;
  with. Public Shared Sub ImportBlock(ByVal BlockFile As String, ByVal BlockName &lt;BR /&gt;
  As String) Dim myDwg As ApplicationServices.Document Dim myDwgLoc As &lt;BR /&gt;
  DocumentLock Dim mySourceDB As New Database Dim myActiveDB As Database 'Read &lt;BR /&gt;
  file and load block into current database Try myDwg = &lt;BR /&gt;
  ApplicationServices.Application.DocumentManager.MdiActiveDocument myDwgLoc = &lt;BR /&gt;
  myDwg.LockDocument() myActiveDB = myDwg.Database &lt;BR /&gt;
  mySourceDB.ReadDwgFile(BlockFile, IO.FileShare.Read, True, "") &lt;BR /&gt;
  myActiveDB.Insert(BlockName, mySourceDB, True) mySourceDB.Dispose() &lt;BR /&gt;
  myDwgLoc.Dispose() Catch ex As Exception MsgBox(ex.Message, &lt;BR /&gt;
  MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error") End Try End Sub &lt;BR /&gt;
  Public Shared Function InsertBlock(ByVal InsPt As Geometry.Point3d, ByVal &lt;BR /&gt;
  BlockName As String, Optional ByVal XScale As Double = 1.0, Optional ByVal &lt;BR /&gt;
  YScale As Double = 1.0, Optional ByVal ZScale As Double = 1.0) As &lt;BR /&gt;
  DatabaseServices.ObjectId Try Dim myTransMan As &lt;BR /&gt;
  DatabaseServices.TransactionManager Dim myTrans As &lt;BR /&gt;
  DatabaseServices.Transaction Dim myDwg As ApplicationServices.Document Dim &lt;BR /&gt;
  myBT As DatabaseServices.BlockTable Dim myBTR As &lt;BR /&gt;
  DatabaseServices.BlockTableRecord Dim myAttColl As &lt;BR /&gt;
  DatabaseServices.AttributeCollection Dim myEnt As DatabaseServices.Entity Dim &lt;BR /&gt;
  myBTREnum As BlockTableRecordEnumerator Dim myDwgLoc As DocumentLock 'Get &lt;BR /&gt;
  active document and begin transaction myDwg = &lt;BR /&gt;
  ApplicationServices.Application.DocumentManager.MdiActiveDocument myDwgLoc = &lt;BR /&gt;
  myDwg.LockDocument() myTransMan = myDwg.TransactionManager myTrans = &lt;BR /&gt;
  myTransMan.StartTransaction 'Open Block Table myBT = &lt;BR /&gt;
  myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead) myBTR = &lt;BR /&gt;
  myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite) &lt;BR /&gt;
  'Insert the Block Dim myBlockDef As BlockTableRecord = &lt;BR /&gt;
  myBT(BlockName).GetObject(OpenMode.ForRead) Dim myBlockRef As New &lt;BR /&gt;
  DatabaseServices.BlockReference(InsPt, myBT(BlockName)) &lt;BR /&gt;
  myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale) &lt;BR /&gt;
  myBTR.AppendEntity(myBlockRef) myTrans.AddNewlyCreatedDBObject(myBlockRef, &lt;BR /&gt;
  True) 'Set Attribute values myAttColl = myBlockRef.AttributeCollection &lt;BR /&gt;
  myBTREnum = myBlockDef.GetEnumerator While myBTREnum.MoveNext myEnt = &lt;BR /&gt;
  myBTREnum.Current.GetObject(OpenMode.ForWrite) If TypeOf myEnt Is &lt;BR /&gt;
  DatabaseServices.AttributeDefinition Then Dim myAttDef As &lt;BR /&gt;
  DatabaseServices.AttributeDefinition = myEnt Dim myAttRef As New &lt;BR /&gt;
  DatabaseServices.AttributeReference myAttRef.SetAttributeFromBlock(myAttDef, &lt;BR /&gt;
  myBlockRef.BlockTransform) myAttColl.AppendAttribute(myAttRef) &lt;BR /&gt;
  myTrans.AddNewlyCreatedDBObject(myAttRef, True) End If End While &lt;BR /&gt;
  myDwgLoc.Dispose() myTrans.Commit() 'Clean up myTrans.Dispose() &lt;BR /&gt;
  myTransMan.Dispose() Return myBlockRef.ObjectId Catch e As Exception &lt;BR /&gt;
  MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error") &lt;BR /&gt;
  End Try End Function Public Shared Sub SetAttributes(ByVal BlockId As &lt;BR /&gt;
  DatabaseServices.ObjectId, ByVal TagList As Collection) Try Dim myTransMan As &lt;BR /&gt;
  DatabaseServices.TransactionManager Dim myTrans As &lt;BR /&gt;
  DatabaseServices.Transaction Dim myDwg As ApplicationServices.Document Dim &lt;BR /&gt;
  myDwgLoc As DocumentLock Dim myBlkRef As DatabaseServices.BlockReference Dim &lt;BR /&gt;
  myAttColl As DatabaseServices.AttributeCollection Dim myEnt As &lt;BR /&gt;
  DatabaseServices.ObjectId Dim myAttRef As DatabaseServices.AttributeReference &lt;BR /&gt;
  'Get active document and begin transaction myDwg = &lt;BR /&gt;
  ApplicationServices.Application.DocumentManager.MdiActiveDocument myDwgLoc = &lt;BR /&gt;
  myDwg.LockDocument() myTransMan = myDwg.TransactionManager myTrans = &lt;BR /&gt;
  myTransMan.StartTransaction 'Find block and set attributes myBlkRef = &lt;BR /&gt;
  BlockId.GetObject(OpenMode.ForWrite) myAttColl = myBlkRef.AttributeCollection &lt;BR /&gt;
  For Each myEnt In myAttColl myAttRef = myEnt.GetObject(OpenMode.ForWrite) Dim &lt;BR /&gt;
  myItem As String Try myItem = TagList(myAttRef.Tag) myAttRef.TextString = &lt;BR /&gt;
  myItem Catch End Try Next myDwgLoc.Dispose() myTrans.Commit() 'Clean up &lt;BR /&gt;
  myTrans.Dispose() myTransMan.Dispose() Catch e As Exception MsgBox(e.Message, &lt;BR /&gt;
  MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen Error") End Try End Sub &lt;BR /&gt;
  Here is how you call them: Dim myBlk As DatabaseServices.ObjectId myBlk = &lt;BR /&gt;
  DwgTools.InsertBlock(New Geometry.Point3d(0, 0, 0), "titlebka") Dim myTags As &lt;BR /&gt;
  New Collection myTags.Add("me", "Drawn_By") myTags.Add("whatever", &lt;BR /&gt;
  "Drawing_Number") DwgTools.SetAttributes(myBlk, myTags) &lt;BR /&gt;
  DwgTools.ImportBlock("f:\autocad_dwgs\symbols\agen\supply1.dwg", "ChrisW") &lt;BR /&gt;
  DwgTools.InsertBlock(New Geometry.Point3d(5, 5, 0), &lt;BR /&gt;
"chrisw")&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 May 2009 14:33:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-a-wblock/m-p/2495649#M70309</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-05-28T14:33:21Z</dc:date>
    </item>
  </channel>
</rss>

