<?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 Block works but problem with update field in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084820#M60227</link>
    <description>&lt;P&gt;I've already searched on the swamp website with no luck so far. If I found the solution I will post it here.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2011 05:08:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-07-08T05:08:53Z</dc:date>
    <item>
      <title>Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3083510#M60223</link>
      <description>&lt;P&gt;I've got a block with multiple attributes. This is not a problem to redefine the blocks attributes.&lt;/P&gt;&lt;P&gt;Some of the attributes contains dynamic fields (blockplace holder x y z parameters)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i insert a block with such atributes that includes the blockplaceholder dynamic fields i get&lt;/P&gt;&lt;P&gt;X: InsertionPoint =&amp;gt; It is recognized as an Dynamic field but displays InsertionPoint. and does not update the value.&lt;/P&gt;&lt;P&gt;Regenerating the modelspace does not help&lt;/P&gt;&lt;P&gt;How can i update the fielddata from vb.net?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this you understand my problem...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of the code I use (where i think the problem is)&lt;/P&gt;&lt;PRE&gt;For Each attid As ObjectId In refbtr
    attent = tr.GetObject(attid, OpenMode.ForRead)
    If TypeOf attent Is AttributeDefinition Then
        Dim attdef As AttributeDefinition = attent
        Dim attref As New AttributeReference()
        attref.SetAttributeFromBlock(attdef, myBlockRef.BlockTransform)
        Dim attrefid As ObjectId = myBlockRef.AttributeCollection.AppendAttribute(attref)
        tr.AddNewlyCreatedDBObject(attref, True)
    End If
Next&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2011 12:06:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3083510#M60223</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-07T12:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084264#M60224</link>
      <description>&lt;P&gt;Maybe it is FIELDEVAL settings.&lt;/P&gt;&lt;P&gt;Take a look at FIELDEVAL system variable and see what the settings is. Set to 16 for update on regen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;﻿﻿</description>
      <pubDate>Thu, 07 Jul 2011 17:57:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084264#M60224</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-07T17:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084358#M60225</link>
      <description>&lt;P&gt;I've already checked that one, (first thing i've thought) but it has no effect on the block attributes.&lt;/P&gt;&lt;P&gt;The UPDATEFIELD command doesn't affect it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I manual do a insert block, select the block from the drop down and place it next to the other the fields work as they are ment to be. So the defenition of the block is not wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I save the drawing and reopen it. The block inserted by the code still appears as InsertionPoint, the manual inserted block displays normal. They both have the exact same contents, the only difference is the way of placing the block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I think my code is not complete.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2011 18:46:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084358#M60225</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-07T18:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084624#M60226</link>
      <description>&lt;P&gt;It looks like you update field from the extension dictionary of the atttribute reference but I have not got anything working or this could be totally off.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will see what I can do later with some more time.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2011 21:42:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084624#M60226</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-07T21:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084820#M60227</link>
      <description>&lt;P&gt;I've already searched on the swamp website with no luck so far. If I found the solution I will post it here.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 05:08:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084820#M60227</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-08T05:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084964#M60228</link>
      <description>&lt;P&gt;See this thread has more info&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://www.theswamp.org/index.php?topic=38857.0"&gt;http://www.theswamp.org/index.php?topic=38857.0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some code from above link&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    &amp;lt;CommandMethod("InsertBlockWithFieldAtts")&amp;gt; _
        Public Sub InsertBlockWithFieldAtts()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            Using trx As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = trx.GetObject(db.BlockTableId, OpenMode.ForRead)
                Dim modelBtr As BlockTableRecord = trx.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
                Dim blockBtr As BlockTableRecord = trx.GetObject(bt("C"), OpenMode.ForRead)
                Dim insertPoint As Point3d = ed.GetPoint("Select Insertion Point").Value
                Dim bref As New BlockReference(insertPoint, blockBtr.ObjectId)
                modelBtr.AppendEntity(bref)
                trx.AddNewlyCreatedDBObject(bref, True)

                For Each id As ObjectId In blockBtr
                    If id.ObjectClass.Name = "AcDbAttributeDefinition" Then
                        Dim attDef As AttributeDefinition = trx.GetObject(id, OpenMode.ForRead)
                        Dim attref As New AttributeReference()
                        attref.SetAttributeFromBlock(attDef, bref.BlockTransform)

                        bref.AttributeCollection.AppendAttribute(attref)
                        trx.AddNewlyCreatedDBObject(attref, True)

                        If attDef.Constant Then
                            Continue For
                        End If

                        Dim extDic As DBDictionary = trx.GetObject(attref.ExtensionDictionary, OpenMode.ForRead)
                        Dim fieldDic As DBDictionary = trx.GetObject(extDic.GetAt("ACAD_FIELD"), OpenMode.ForRead)
                        Dim fld As Field = trx.GetObject(fieldDic.GetAt("TEXT"), OpenMode.ForWrite)

                        Dim strId As String = bref.ObjectId.OldIdPtr.ToString()
                        Dim updteStr As String = "%&amp;lt;\_ObjId " &amp;amp; strId &amp;amp; "&amp;gt;%"
                        Dim fieldCode As String = fld.GetFieldCode(FieldCodeFlags.AddMarkers)
                        Dim newFieldCode As String = fieldCode.Replace("?BlockRefId", updteStr)
                        fld.SetFieldCode(newFieldCode)

                    End If
                Next
                trx.Commit()
            End Using
            ed.Regen()
        End Sub

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 09:36:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084964#M60228</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-08T09:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Insert Block works but problem with update field</title>
      <link>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084980#M60229</link>
      <description>&lt;P&gt;Thanks man! Problem solved!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2011 10:00:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/insert-block-works-but-problem-with-update-field/m-p/3084980#M60229</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-07-08T10:00:16Z</dc:date>
    </item>
  </channel>
</rss>

