<?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: Null Reference Exception in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11179713#M36954</link>
    <description>&lt;P&gt;I'm not familiary with VBA, but I believe you need to write 'Set' in front of new objects. This is an example from the api helper. It can be found by clicking the drop down for the (?) in the top right &amp;gt; Help &amp;gt; Programming/API help.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;Public Sub CreateCustomTable()
    &lt;SPAN&gt;' Set a reference to the drawing document.&lt;/SPAN&gt;
    &lt;SPAN&gt;' This assumes a drawing document is active.&lt;/SPAN&gt;
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 May 2022 12:29:47 GMT</pubDate>
    <dc:creator>dalton98</dc:creator>
    <dc:date>2022-05-19T12:29:47Z</dc:date>
    <item>
      <title>Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178279#M36951</link>
      <description>&lt;P&gt;its been a few years since ive gotten my hands dirty with writing code for Inventor and im getting an error when i test a few lines of code and i cant figure out why. if i open old projects and run the code everything works. so i have a Drawing open in Inventor and i have two custom iProperties on the drawing that is blank at the moment and i have a small vb.net UI with a button, when i click the button im trying to populate the custom iProperties with values hard coded just as a test to get the code correct. Line 4 throws me a Null Reference Exception. can anyone explain what im missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim oStation As String = "Test"&lt;BR /&gt;Dim oStationID As String = "Test ID"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim oApp As Inventor.Application = GetObject(, "Inventor.Application")&lt;BR /&gt;Dim oDoc As DrawingDocument = oApp.ActiveDocument&amp;nbsp; &amp;nbsp; &amp;nbsp;'&amp;lt;-------Problem Line-----&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim oCustomiProp As PropertySet&lt;BR /&gt;oCustomiProp = oDoc.PropertySets.Item("Inventor User Defined Properties")&lt;/P&gt;&lt;P&gt;oCustomiProp.Item("Station").Value = oStation&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 20:24:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178279#M36951</guid>
      <dc:creator>jpchaisson</dc:creator>
      <dc:date>2022-05-18T20:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178399#M36952</link>
      <description>&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oObj&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; = &lt;SPAN&gt;"Inventor.Application"&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oApp&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Inventor&lt;/SPAN&gt;.&lt;SPAN&gt;Application&lt;/SPAN&gt; = &lt;SPAN&gt;GetObject&lt;/SPAN&gt;(, &lt;SPAN&gt;oObj&lt;/SPAN&gt;)
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;DrawingDocument&lt;/SPAN&gt;
&lt;SPAN&gt;oDoc&lt;/SPAN&gt; = &lt;SPAN&gt;oApp&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2022 21:24:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178399#M36952</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-05-18T21:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178787#M36953</link>
      <description>&lt;P&gt;Still getting a Null Reference.... i am really confused this is such a simple line of code and ive never gotten this before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jpchaisson_0-1652930224346.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1069063i20CA100BDEAF76E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jpchaisson_0-1652930224346.png" alt="jpchaisson_0-1652930224346.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 03:16:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11178787#M36953</guid>
      <dc:creator>jpchaisson</dc:creator>
      <dc:date>2022-05-19T03:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11179713#M36954</link>
      <description>&lt;P&gt;I'm not familiary with VBA, but I believe you need to write 'Set' in front of new objects. This is an example from the api helper. It can be found by clicking the drop down for the (?) in the top right &amp;gt; Help &amp;gt; Programming/API help.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;Public Sub CreateCustomTable()
    &lt;SPAN&gt;' Set a reference to the drawing document.&lt;/SPAN&gt;
    &lt;SPAN&gt;' This assumes a drawing document is active.&lt;/SPAN&gt;
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 12:29:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11179713#M36954</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-05-19T12:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11180118#M36955</link>
      <description>&lt;P&gt;This is VB.NET not VBA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive never had this problem before. its driving me crazy. everything looks correct&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 14:57:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11180118#M36955</guid>
      <dc:creator>jpchaisson</dc:creator>
      <dc:date>2022-05-19T14:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11183179#M36956</link>
      <description>&lt;P&gt;Follow this link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/simplecontent/content/lesson-1-the-basic-plug--E2-80-93-autodesk-inventor.html" target="_blank" rel="noopener"&gt;https://knowledge.autodesk.com/search-result/caas/simplecontent/content/lesson-1-the-basic-plug--E2-80-93-autodesk-inventor.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I copy and pasted ur code and it worked fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 18:46:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11183179#M36956</guid>
      <dc:creator>dalton98</dc:creator>
      <dc:date>2022-05-20T18:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11183203#M36957</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/891346"&gt;@jpchaisson&lt;/a&gt;.&amp;nbsp; It is possible to have the Inventor application open, without actually having any documents open.&amp;nbsp; Could that possibly be the case here?&amp;nbsp; Then there is the situation where you might have multiple instances of Inventor open...one with 1 or more documents open, and the other with no documents open, and maybe your code is grabbing the instance without any open documents.&amp;nbsp; Just throwing some stuff out there.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 18:44:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11183203#M36957</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2022-05-20T18:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Null Reference Exception</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11184064#M36958</link>
      <description>&lt;P&gt;try replacing the line:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oApp As Inventor.Application = GetObject(, "Inventor.Application")&lt;/LI-CODE&gt;
&lt;P&gt;with the following:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oApp As Inventor.Application =  System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 21 May 2022 10:27:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/null-reference-exception/m-p/11184064#M36958</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2022-05-21T10:27:57Z</dc:date>
    </item>
  </channel>
</rss>

