<?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 need help debugging code in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/need-help-debugging-code/m-p/2661679#M66059</link>
    <description>Hi. I need help here. There is an error in my code when I run the program in autocad. Im using vb.net. The line where the error is in denoted by &amp;lt;----. Error is Object reference not set to an instance of an object.&lt;BR /&gt;
&lt;BR /&gt;
            Dim myDWG As ApplicationServices.Document&lt;BR /&gt;
            Dim myDB As DatabaseServices.Database&lt;BR /&gt;
            Dim myEd As EditorInput.Editor&lt;BR /&gt;
            Dim myPSR As EditorInput.PromptSelectionResult&lt;BR /&gt;
            Dim mySS As EditorInput.SelectionSet&lt;BR /&gt;
            Dim myFilter(0) As DatabaseServices.TypedValue&lt;BR /&gt;
            Dim myObjIds As DatabaseServices.ObjectIdCollection&lt;BR /&gt;
            Dim myObjId As DatabaseServices.ObjectId&lt;BR /&gt;
            Dim myEnt As DatabaseServices.Entity&lt;BR /&gt;
            myFilter(0) = New DatabaseServices.TypedValue(DatabaseServices.DxfCode.BlockName, "aaa")&lt;BR /&gt;
            Dim mySF As New EditorInput.SelectionFilter(myFilter)&lt;BR /&gt;
            Dim maxPt As Geometry.Point3d&lt;BR /&gt;
            Dim minPt As Geometry.Point3d&lt;BR /&gt;
            Dim dist As Double&lt;BR /&gt;
            myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
            myDB = myDWG.Database&lt;BR /&gt;
            myEd = myDWG.Editor&lt;BR /&gt;
            myPSR = myEd.SelectAll(mySF)&lt;BR /&gt;
            If Not IsNothing(myPSR.Value) Then&lt;BR /&gt;
                mySS = myPSR.Value&lt;BR /&gt;
                    myObjIds = New DatabaseServices.ObjectIdCollection(mySS.GetObjectIds)&lt;BR /&gt;
                    For Each myObjId In myObjIds&lt;BR /&gt;
                        myEnt = myObjId.GetObject(DatabaseServices.OpenMode.ForRead)  &amp;lt;------ error here&lt;BR /&gt;
                    Next&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
Edited by: a7v1n on Apr 6, 2010 8:19 PM</description>
    <pubDate>Tue, 06 Apr 2010 20:18:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-04-06T20:18:29Z</dc:date>
    <item>
      <title>need help debugging code</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-help-debugging-code/m-p/2661679#M66059</link>
      <description>Hi. I need help here. There is an error in my code when I run the program in autocad. Im using vb.net. The line where the error is in denoted by &amp;lt;----. Error is Object reference not set to an instance of an object.&lt;BR /&gt;
&lt;BR /&gt;
            Dim myDWG As ApplicationServices.Document&lt;BR /&gt;
            Dim myDB As DatabaseServices.Database&lt;BR /&gt;
            Dim myEd As EditorInput.Editor&lt;BR /&gt;
            Dim myPSR As EditorInput.PromptSelectionResult&lt;BR /&gt;
            Dim mySS As EditorInput.SelectionSet&lt;BR /&gt;
            Dim myFilter(0) As DatabaseServices.TypedValue&lt;BR /&gt;
            Dim myObjIds As DatabaseServices.ObjectIdCollection&lt;BR /&gt;
            Dim myObjId As DatabaseServices.ObjectId&lt;BR /&gt;
            Dim myEnt As DatabaseServices.Entity&lt;BR /&gt;
            myFilter(0) = New DatabaseServices.TypedValue(DatabaseServices.DxfCode.BlockName, "aaa")&lt;BR /&gt;
            Dim mySF As New EditorInput.SelectionFilter(myFilter)&lt;BR /&gt;
            Dim maxPt As Geometry.Point3d&lt;BR /&gt;
            Dim minPt As Geometry.Point3d&lt;BR /&gt;
            Dim dist As Double&lt;BR /&gt;
            myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
            myDB = myDWG.Database&lt;BR /&gt;
            myEd = myDWG.Editor&lt;BR /&gt;
            myPSR = myEd.SelectAll(mySF)&lt;BR /&gt;
            If Not IsNothing(myPSR.Value) Then&lt;BR /&gt;
                mySS = myPSR.Value&lt;BR /&gt;
                    myObjIds = New DatabaseServices.ObjectIdCollection(mySS.GetObjectIds)&lt;BR /&gt;
                    For Each myObjId In myObjIds&lt;BR /&gt;
                        myEnt = myObjId.GetObject(DatabaseServices.OpenMode.ForRead)  &amp;lt;------ error here&lt;BR /&gt;
                    Next&lt;BR /&gt;
            End If&lt;BR /&gt;
&lt;BR /&gt;
Edited by: a7v1n on Apr 6, 2010 8:19 PM</description>
      <pubDate>Tue, 06 Apr 2010 20:18:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-help-debugging-code/m-p/2661679#M66059</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-06T20:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: need help debugging code</title>
      <link>https://forums.autodesk.com/t5/net-forum/need-help-debugging-code/m-p/2661680#M66060</link>
      <description>Firstly, do not use&lt;BR /&gt;
&lt;BR /&gt;
If Not IsNothing(myPSR.Value) Then&lt;BR /&gt;
...&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
to test if the PromptSelectionresult is OK or not. Editor.SelectAll() always returns a non-null PromptSelectionResult object, so your IsNothing() test is useless. Instead, you should examine PromptSelectionResult.Status property to see if the SelecAll() method grabs something or not.&lt;BR /&gt;
&lt;BR /&gt;
Secondly, you need to place GetObject() within a scope of transaction.</description>
      <pubDate>Tue, 06 Apr 2010 21:37:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/need-help-debugging-code/m-p/2661680#M66060</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2010-04-06T21:37:35Z</dc:date>
    </item>
  </channel>
</rss>

