I'm getting an infrequent error with my code. Occasionally I get this error:
What does this mean and how can I fix it? Here's my code:
Dim doc as AssemblyDocument = ThisDoc.Document Dim oAsmCompDef As ComponentDefinition oAsmCompDef = doc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence For Each oCompOcc in oAsmCompDef.Occurrences oCompOcc.SetDesignViewRepresentation("Default", True) Next ThisApplication.ActiveView.Fit
Any help would be greatly appreciated. Thanks guys.
Hi,
When trying to find the issue, first you can try to comment out more and more of your code until the error goes away.
In your case the first choice would be commenting out
oCompOcc.SetDesignViewRepresentation
Then if you found the line where the error happens, you can place it inside a try/catch and bring up a dialog with some info about the object where the error happened. E.g.:
Dim doc as AssemblyDocument = ThisDoc.Document Dim oDim doc as AssemblyDocument = ThisDoc.Document Dim oAsmCompDef As ComponentDefinition oAsmCompDef = doc.ComponentDefinition Dim oCompOcc As Inventor.ComponentOccurrence For Each oCompOcc in oAsmCompDef.Occurrences Try oCompOcc.SetDesignViewRepresentation("Default", True) Catch MsgBox(oCompOcc.Name) End Try Next ThisApplication.ActiveView.Fit
Then try to make the same changes for the same object through the UI as well - it will probably fail there too, which should give you an idea about how to solve it.
Cheers,