<?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: Selection Filter Error -5001 in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7988153#M26038</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/786488"&gt;@SRSDS&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;Does sounds like that’s the problem.&lt;/P&gt;&lt;P&gt;Hopefully it’s not that bad but it’ll take a while to fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have objects grouped together using a ReferenceID in their entity XData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TypedValue(DxfCode.ExtendedDataRegAppName, "MyApp-" &amp;amp; ReferenceID)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Each ReferenceID has a NOD entry which includes associated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could I include a string list of object Handles to that entry buffer?&lt;/P&gt;&lt;P&gt;Adding and removing them if entities are added, cloned or deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least then I could still quickly identify the set&amp;nbsp;&lt;SPAN&gt;ReferenceID&amp;nbsp;&lt;/SPAN&gt;and any associated objects.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Storing a reference to one object within another object can't be done reliably using handles in xdata. Inserting, WBlock'ing, and copying objects will break the references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to use an XRecord in an extension dictionary, and store the ObjectIds of the referenced objects using the appropriate &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-3F0380A5-1C15-464D-BC66-2C5F094BCFB9" target="_blank"&gt;dxf codes&lt;/A&gt;&amp;nbsp;(330-369). You also have to set the Xrecord's XlateReferences property to true.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 May 2018 18:33:10 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2018-05-08T18:33:10Z</dc:date>
    <item>
      <title>Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7982597#M26030</link>
      <description>&lt;P&gt;I have a problem with the selection filter returning an error (-5001).&lt;/P&gt;&lt;P&gt;I've narrowed it down..the problem only starts to occur after I've added Xdata to an entity.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The selection filter works before that section of code.&lt;/P&gt;&lt;P&gt;Another odd thing is that the filter works if I use StartTransaction instead of&amp;nbsp;&lt;SPAN&gt;StartOpenCloseTransaction&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;But because it's an event I've been advised that I should be using&amp;nbsp;&lt;SPAN&gt;StartOpenCloseTransaction.&lt;/SPAN&gt;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 May 2018 00:17:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7982597#M26030</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2018-05-06T00:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7985871#M26031</link>
      <description>&lt;P&gt;This is a summary of the code with the problem&lt;/P&gt;&lt;PRE&gt;    Private Sub callback_CommandEnded(ByVal sender As Object, ByVal e As CommandEventArgs)
        If e.GlobalCommandName = "GRIP_STRETCH" Then
            Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
                Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartOpenCloseTransaction : trcnt = trcnt + 1
                    Dim ent As Entity = TryCast(trans.GetObject(ObjID, OpenMode.ForRead), Entity)
                    'Filter Works fine here
                    'Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
                    'Dim values As TypedValue() = New TypedValue() {New TypedValue(CType(DxfCode.ExtendedDataRegAppName, Short), "BarLabel-2")}
                    'Dim filter As SelectionFilter = New SelectionFilter(values)
                    'psr = ed.SelectAll(filter)
                    'If psr.Status = PromptStatus.OK Then
                    'End If
                    WriteXdata(SomeOtherObjID, trans)
                    'Same Filter Doesn't
                    trans.Commit()
                End Using
            End Using
        End If
    End sub&lt;/PRE&gt;&lt;P&gt;Do I need to commit a StartOpenCloseTransaction after writing Xdata before trying to filter xdata?&lt;/P&gt;&lt;P&gt;Strange that the same problem doesn't occur with StartTransaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 23:39:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7985871#M26031</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2018-05-07T23:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7985983#M26032</link>
      <description>&lt;P&gt;I can't tell you why you're seeing the problem you cite, but I'm not sure I follow the logic of your code. You are selecting all objects with Xdata for a certain application name from within a command-ended notification for the GRIP_STRETCH command.&amp;nbsp; If you're trying to act on the object(s) that were actually modified by the GRIP_STRETCH command, how are you identifying which of those were modified?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/786488"&gt;@SRSDS&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;This is a summary of the code with the problem&lt;/P&gt;&lt;PRE&gt;    Private Sub callback_CommandEnded(ByVal sender As Object, ByVal e As CommandEventArgs)
        If e.GlobalCommandName = "GRIP_STRETCH" Then
            Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
                Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartOpenCloseTransaction : trcnt = trcnt + 1
                    Dim ent As Entity = TryCast(trans.GetObject(ObjID, OpenMode.ForRead), Entity)
                    'Filter Works fine here
                    'Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
                    'Dim values As TypedValue() = New TypedValue() {New TypedValue(CType(DxfCode.ExtendedDataRegAppName, Short), "BarLabel-2")}
                    'Dim filter As SelectionFilter = New SelectionFilter(values)
                    'psr = ed.SelectAll(filter)
                    'If psr.Status = PromptStatus.OK Then
                    'End If
                    WriteXdata(SomeOtherObjID, trans)
                    'Same Filter Doesn't
                    trans.Commit()
                End Using
            End Using
        End If
    End sub&lt;/PRE&gt;&lt;P&gt;Do I need to commit a StartOpenCloseTransaction after writing Xdata before trying to filter xdata?&lt;/P&gt;&lt;P&gt;Strange that the same problem doesn't occur with StartTransaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 01:02:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7985983#M26032</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-05-08T01:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986026#M26033</link>
      <description>&lt;P&gt;I am&amp;nbsp;acting on the object that was modified.&lt;/P&gt;&lt;PRE&gt;    Public Shared Sub callback_ObjectModified(ByVal sender As Object, ByVal e As ObjectEventArgs)
        If GripStretchEvent = True And e.DBObject.XData IsNot Nothing Then
            Dim myXdata As Array = e.DBObject.XData.AsArray
            Dim arrSplit() As String = myXdata.GetValue(0).value.Split("-")
            If arrSplit(0) = "ABC"  Then
                ObjID = e.DBObject.ObjectId
            End If
        End If
        'NOTE TO SELF: USE THIS EVENT ONLY TO COLLECT OBJID
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 01:33:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986026#M26033</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2018-05-08T01:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986514#M26034</link>
      <description>&lt;P&gt;I still do not see what your purpose of using SelectAll() from a CommandEnded event handler is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/786488"&gt;@SRSDS&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;I am&amp;nbsp;acting on the object that was modified.&lt;/P&gt;&lt;PRE&gt;    Public Shared Sub callback_ObjectModified(ByVal sender As Object, ByVal e As ObjectEventArgs)
        If GripStretchEvent = True And e.DBObject.XData IsNot Nothing Then
            Dim myXdata As Array = e.DBObject.XData.AsArray
            Dim arrSplit() As String = myXdata.GetValue(0).value.Split("-")
            If arrSplit(0) = "ABC"  Then
                ObjID = e.DBObject.ObjectId
            End If
        End If
        'NOTE TO SELF: USE THIS EVENT ONLY TO COLLECT OBJID
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 07:54:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986514#M26034</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-05-08T07:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986538#M26035</link>
      <description>&lt;P&gt;Once the grip is stretched it filters out other entites with specific Appname Xdata and modifies them (and their XData) with any updated information. Probably got some terminology wrong&amp;nbsp;in writing this.&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;&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>Tue, 08 May 2018 08:07:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7986538#M26035</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2018-05-08T08:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7987340#M26036</link>
      <description>&lt;P&gt;My guess on why you're having this problem is because you can't use SelectAll() or any other SelectXxxx() method in some, if not all event handlers, because those methods &lt;EM&gt;&lt;STRONG&gt;modify the previous selection set&lt;/STRONG&gt;&lt;/EM&gt;. Technically, You should never do anything that changes the previous selection set from what the user expects it to be.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can scan the database for the objects manually, rather than use SelectAll(), or you can store references to the objects you're trying to find in an extension dictionary attached to the object that's being modified, but that also requires you to deal with cloning.&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 14:00:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7987340#M26036</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-05-08T14:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7988106#M26037</link>
      <description>&lt;P&gt;Does sounds like that’s the problem.&lt;/P&gt;&lt;P&gt;Hopefully it’s not that bad but it’ll take a while to fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have objects grouped together using a ReferenceID in their entity XData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TypedValue(DxfCode.ExtendedDataRegAppName, "MyApp-" &amp;amp; ReferenceID)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Each ReferenceID has a NOD entry which includes associated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could I include a string list of object Handles to that entry buffer?&lt;/P&gt;&lt;P&gt;Adding and removing them if entities are added, cloned or deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least then I could still quickly identify the set&amp;nbsp;&lt;SPAN&gt;ReferenceID&amp;nbsp;&lt;/SPAN&gt;and any associated objects.&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 18:14:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7988106#M26037</guid>
      <dc:creator>SRSDS</dc:creator>
      <dc:date>2018-05-08T18:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Filter Error -5001</title>
      <link>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7988153#M26038</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/786488"&gt;@SRSDS&lt;/a&gt;wrote:&lt;BR /&gt;&lt;P&gt;Does sounds like that’s the problem.&lt;/P&gt;&lt;P&gt;Hopefully it’s not that bad but it’ll take a while to fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have objects grouped together using a ReferenceID in their entity XData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TypedValue(DxfCode.ExtendedDataRegAppName, "MyApp-" &amp;amp; ReferenceID)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Each ReferenceID has a NOD entry which includes associated data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could I include a string list of object Handles to that entry buffer?&lt;/P&gt;&lt;P&gt;Adding and removing them if entities are added, cloned or deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least then I could still quickly identify the set&amp;nbsp;&lt;SPAN&gt;ReferenceID&amp;nbsp;&lt;/SPAN&gt;and any associated objects.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Storing a reference to one object within another object can't be done reliably using handles in xdata. Inserting, WBlock'ing, and copying objects will break the references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to use an XRecord in an extension dictionary, and store the ObjectIds of the referenced objects using the appropriate &lt;A href="http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-3F0380A5-1C15-464D-BC66-2C5F094BCFB9" target="_blank"&gt;dxf codes&lt;/A&gt;&amp;nbsp;(330-369). You also have to set the Xrecord's XlateReferences property to true.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 18:33:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/selection-filter-error-5001/m-p/7988153#M26038</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-05-08T18:33:10Z</dc:date>
    </item>
  </channel>
</rss>

