Null Reference Exception
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oStation As String = "Test"
Dim oStationID As String = "Test ID"
Dim oApp As Inventor.Application = GetObject(, "Inventor.Application")
Dim oDoc As DrawingDocument = oApp.ActiveDocument '<-------Problem Line-----
Dim oCustomiProp As PropertySet
oCustomiProp = oDoc.PropertySets.Item("Inventor User Defined Properties")
oCustomiProp.Item("Station").Value = oStation
End Sub