Message 1 of 4

Not applicable
09-21-2010
12:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Since we have Inventor 2011 I have a strange error in my add-in. Sometimes when I open a file and run my add-in I get this error:
"Object reference not set to an instance of an object"
When I close the file and try it again, the same error is there. When I restart Inventor and open the same file then the problem is gone. In Inventor 2009 I have never had this error.
The add-in gives me the BOM structure of the active document. See the code below and the line that gives the problem.
Dim oDef As Inventor.ComponentDefinition Dim oDoc As Inventor.Document = IV.ActiveDocument 'next line gives the error: oDef = oDoc.ComponentDefinition Dim BS As Integer If oDef.BOMStructure = 51970 Then BS = 0 ElseIf oDef.BOMStructure = 51974 Then BS = 1 ElseIf oDef.BOMStructure = 51973 Then BS = 2 ElseIf oDef.BOMStructure = 51971 Then BS = 3 ElseIf oDef.BOMStructure = 51972 Then BS = 4 End If
I hope someone can tell me how to solve this.
Wim
Solved! Go to Solution.