Message 1 of 6
Referenced File Descriptor Fails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using the following code to traverse an assembly and print out the parts within it:
Public Sub TraverseAssemblySample() ' Get the active assembly. Dim fso As New FileSystemObject Dim OApp As Inventor.Application Set OApp = GetObject(, "Inventor.Application") Dim oAsmDoc As Inventor.AssemblyDocument Set oAsmDoc = OApp.ActiveDocument Debug.Print oAsmDoc.DisplayName ' Call the function that does the recursion. Call TraverseAssembly(oAsmDoc.ComponentDefinition.Occurrences, 1) End Sub Private Sub TraverseAssembly(Occurrences As ComponentOccurrences, Level As Integer) ' Iterate through all of the occurrence in this collection. This ' represents the occurrences at the top level of an assembly. Dim oOcc As ComponentOccurrence For Each oOcc In Occurrences ' Print the name of the current occurrence. Debug.Print Space(Level * 3) & oOcc.DefinitionReference.ReferencedFileDescriptor.DisplayName ' Check to see if this occurrence represents a subassembly ' and recursively call this function to traverse through it. If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.SubOccurrences, Level + 1) End If Next End Sub
The problem I have is the ReferencedFileDescriptor fails with the following message:
This error occurs here:
Debug.Print Space(Level * 3) & oOcc.DefinitionReference.ReferencedFileDescriptor.DisplayName
This is code which is from the Autodesk site but the worrying thing is this issue is completely random. It will work without issues on an assembly then another time I will get this error. Each time I get the error, it is with a different part file!! I get the error on different parts on different assemblies at different times.
Has anyone encountered this?
Thanks