Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
Im using inventor 2022 and I have a bug in my code that I do not understeand
This code works great for normal parts, but when my part has multiple modelstates, and
I run the code not 1 BUT 2x , the second time i get a error at line "Dim oParameter as....."
Sub TestSub()
Dim oDoc As Document = Nothing
Dim oOcc As ComponentOccurrence = Nothing
Dim oTG As TransientGeometry = App.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim Path As String = "C:\...\example.ipt"
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))
'oMatrix.SetToRotation(Angle, oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0))
oOcc = App.ActiveDocument.ComponentDefinition.Occurrences.Add(Path, oMatrix)
oDoc = oOcc.Definition.Document
oDoc.Update2()
Dim oParameter As Parameter = oDoc.ComponentDefinition.Parameters.Item("myParam")
oParameter.Value = "10"
oDoc.Update2()
oDoc.Save2()
oDoc.Close()
App.ActiveDocument.Update2()
End Sub
Solved! Go to Solution.