<?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: How to amend object in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251502#M58065</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you checked that one of these two lines are executed (&lt;FONT face="lucida sans unicode,lucida sans"&gt;.TextString&lt;/FONT&gt; is modified)?&lt;/P&gt;&lt;PRE&gt;Case 5 : ar.TextString = .JobNo
Case 6, 7, 8, 9 : ar.TextString = .Description(i - 6)&lt;/PRE&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
    <pubDate>Tue, 06 Dec 2011 13:49:24 GMT</pubDate>
    <dc:creator>Alfred.NESWADBA</dc:creator>
    <dc:date>2011-12-06T13:49:24Z</dc:date>
    <item>
      <title>How to amend object</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251244#M58062</link>
      <description>&lt;P&gt;This is my code (thanks to Alfred NESWADBA)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   Friend Sub ObjectModified(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
      Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
         Dim btr As BlockTableRecord
         btr = tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite)
         With e.DBObject
            If .IsWriteEnabled Then Exit Sub
            If .Id.ObjectClass.Name = "AcDbAttribute" Then
               Dim ar As AttributeReference = CType(e.DBObject, AttributeReference)
               Dim blk As BlockReference = tr.GetObject(ar.OwnerId, OpenMode.ForRead)
               blk.SetDatabaseDefaults()
               With a_Job
                  For i As Integer = 4 To 19
                     If a_Title.Tags(i) = ar.Tag Then
                        Select Case i
                           Case 4, 5, 6, 7
                              Dim a As String = .Description(i - 4)
                              ar.UpgradeOpen()
                              ar.TextString = a
                              tr.AddNewlyCreatedDBObject(ar, False)
                        End Select
                     End If
                  Next i
               End With
            End If
         End With
         tr.Commit()
      End Using
   End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Naturally it doesn;t work. Actually it crashes AutoCad&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 09:32:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251244#M58062</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-12-06T09:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to amend object</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251252#M58063</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) the event ObjectModified gets fired when objects are modified, but at least not ready for you, so it's always critical if you try to do any modifications within this eventhandler ... modifications to other than the current obj.&lt;/P&gt;&lt;P&gt;2) why do you do this: "&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;blk.SetDatabaseDefaults&lt;/FONT&gt;" because the block is already inserted and already has it's properties set, what should that be for? And as you don't need to do that, you also need not open the BlockReference for read- or write-acess!&lt;/P&gt;&lt;P&gt;3) we don't know what "&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;a_Job&lt;/FONT&gt;" is, please let's see what type that is&lt;/P&gt;&lt;P&gt;4) and most critical (and sorry ... wrong) is this part:&lt;/P&gt;&lt;PRE&gt;ar.UpgradeOpen()
ar.TextString = a
&lt;EM&gt;&lt;FONT color="#666699"&gt;tr.AddNewlyCreatedDBObject(ar, False)&lt;/FONT&gt;&lt;/EM&gt;&lt;/PRE&gt;&lt;P&gt;Here you open an object to get write-access, you modify it and then you try to add this object again to the database! An object (I guess it's an AttributeReference) that already is placed in the database can't be added to the database once more! So remove the AddNewlyCreated.... statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 09:51:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251252#M58063</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2011-12-06T09:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to amend object</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251340#M58064</link>
      <description>&lt;P&gt;I amended the code thus:-&lt;/P&gt;&lt;PRE&gt;   Friend Sub ObjectModified(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
      Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
         With e.DBObject
            If .IsWriteEnabled Then Exit Sub
            If .Id.ObjectClass.Name = "AcDbAttribute" Then
               Dim ar As AttributeReference = CType(e.DBObject, AttributeReference)
               With a_Job
                  ar.UpgradeOpen()
                  For i As Integer = 5 To 9
                     If a_Title.Tags(i) = ar.Tag Then
                        Select Case i
                           Case 5 : ar.TextString = .JobNo
                           Case 6, 7, 8, 9 : ar.TextString = .Description(i - 6)
                        End Select
                     End If
                  Next i
               End With
            End If
         End With
         tr.Commit()
      End Using
   End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;a_Title is a class which contains a list of tag strings, which I look for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However the block is not updated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You didn't comment on this code, which I had and removed because it seemed redundant to me.&lt;/P&gt;&lt;PRE&gt;         Dim btr As BlockTableRecord
         btr = tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;and I don't see how to update the block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 11:38:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251340#M58064</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-12-06T11:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to amend object</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251502#M58065</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you checked that one of these two lines are executed (&lt;FONT face="lucida sans unicode,lucida sans"&gt;.TextString&lt;/FONT&gt; is modified)?&lt;/P&gt;&lt;PRE&gt;Case 5 : ar.TextString = .JobNo
Case 6, 7, 8, 9 : ar.TextString = .Description(i - 6)&lt;/PRE&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 13:49:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251502#M58065</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2011-12-06T13:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to amend object</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251894#M58066</link>
      <description>&lt;P&gt;Yes they are.&lt;/P&gt;&lt;P&gt;and JobNo &amp;lt;&amp;gt;"" etc.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2011 16:43:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-amend-object/m-p/3251894#M58066</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-12-06T16:43:19Z</dc:date>
    </item>
  </channel>
</rss>

