<?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: Using Object Modified Event to collect moved objects in move command problem in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3225050#M58515</link>
    <description>&lt;P&gt;Hi Janet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure why the ObjectId's are being duplicated in your collection. I looked at the Database.ObjectModified event when using the MOVE command, and for me it was only fired once for each moved item. Note: I'm using AutoCAD 2012.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if this is not what is happening for you, my thoughts would be that you could:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Use the Document.CommandWillStart event with the MOVE command to register the Database.ObjectModified event. I believe this is what you have done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. In the Database.ObjectModified event handler, first check if the ObjectIdCollection already contains the ObjectId, i.e use the ObjectIdCollection.Contains() function, and if not then add the ObjectId to the collection. This will prevent any duplication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Use the Document.CommandWillEnd event with the MOVE command to un-register the Database.ObjectModified event, and then do whatever you need to do with the ObjectIdCollection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2011 00:54:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-11-11T00:54:37Z</dc:date>
    <item>
      <title>Using Object Modified Event to collect moved objects in move command problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3218748#M58514</link>
      <description>&lt;P&gt;Hello, I have a problem . Hope somebody could correct me. I am going to collect objectid's of the moved items in drawing after they moved to destination. So I wrote an event to monitor move command ,&amp;nbsp;by using object modified event handler.&amp;nbsp; when I run below code for every entity it collects 2 object id. One before move and one after move. Is there any way to just collect object ids after they moved?&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;P&gt;Janet.&lt;/P&gt;&lt;PRE&gt;Class EVENTS
    Dim MyDwg As Document = Application.DocumentManager.MdiActiveDocument
    Dim Myed As Editor = MyDwg.Editor
    Dim Mydb As Database = MyDwg.Database
    Dim Myobjidcoll As ObjectIdCollection
    Sub On_Command_Will_Start(ByVal sender As Object, ByVal e As CommandEventArgs)
        Select Case e.GlobalCommandName
            Case "MOVE"
                Dim Myobjidcoll As New ObjectIdCollection
                AddHandler Mydb.ObjectModified, AddressOf Myobj_Moved
        End Select
    End Sub
    Sub Myobj_moved(ByVal sender As Object, ByVal e As ObjectEventArgs)
        Myobjidcoll.Add(e.DBObject.ObjectId)
    End Sub
End Class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 05:36:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3218748#M58514</guid>
      <dc:creator>JanetDavidson</dc:creator>
      <dc:date>2011-11-07T05:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using Object Modified Event to collect moved objects in move command problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3225050#M58515</link>
      <description>&lt;P&gt;Hi Janet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure why the ObjectId's are being duplicated in your collection. I looked at the Database.ObjectModified event when using the MOVE command, and for me it was only fired once for each moved item. Note: I'm using AutoCAD 2012.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if this is not what is happening for you, my thoughts would be that you could:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Use the Document.CommandWillStart event with the MOVE command to register the Database.ObjectModified event. I believe this is what you have done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. In the Database.ObjectModified event handler, first check if the ObjectIdCollection already contains the ObjectId, i.e use the ObjectIdCollection.Contains() function, and if not then add the ObjectId to the collection. This will prevent any duplication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Use the Document.CommandWillEnd event with the MOVE command to un-register the Database.ObjectModified event, and then do whatever you need to do with the ObjectIdCollection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2011 00:54:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3225050#M58515</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-11T00:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Object Modified Event to collect moved objects in move command problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3225060#M58516</link>
      <description>&lt;P&gt;Just had another thought.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could it be that your code registers the Database.ObjectModified event handler more than once?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your snippet, it might be that each time you start the MOVE command, you are "adding" another event handler. In other words you might end up with the same event handler being fired multiple times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you included code to un-register the Database.ObjectModified event handler when the MOVE command has finished?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2011 01:04:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3225060#M58516</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-11T01:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using Object Modified Event to collect moved objects in move command problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3226152#M58517</link>
      <description>&lt;P&gt;Hello Artvegas&lt;/P&gt;&lt;P&gt;well never thought of that. I checked it and yes your are right. object modify fires 2 times.&lt;/P&gt;&lt;P&gt;Thank you very much. Sometimes without help&amp;nbsp; brain doesn't work.&lt;/P&gt;&lt;P&gt;Cheers Artvegas.&lt;/P&gt;&lt;P&gt;Janet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2011 06:23:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/using-object-modified-event-to-collect-moved-objects-in-move/m-p/3226152#M58517</guid>
      <dc:creator>JanetDavidson</dc:creator>
      <dc:date>2011-11-12T06:23:04Z</dc:date>
    </item>
  </channel>
</rss>

