How to tell if an assembly is missing file references via API/iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When we open an assembly file with missing references, Inventor displays the question mark to the left of the file's name in the browser tree. I'm trying to figure out how to determine via iLogic/the API whether a document is in this "unresolved references" state. I don't really care about any missing "imported AutoCAD" references or anything like that, I only want to know if the assembly is missing references that would prevent the BOM from opening.
The best way I've come up with is to use a function like below to recurse through all file references and check if any of them are missing, and if so check if they're component (part or assembly) files:
Sub Main() MsgBox("Is missing references: " & IsMissingReferencesRecursive(ThisDoc.Document.File.ReferencedFileDescriptors)) End Sub
Function IsMissingReferencesRecursive(fileDescriptors As FileDescriptorsEnumerator) As Boolean For Each refFileDesc As FileDescriptor In fileDescriptors If refFileDesc.ReferenceMissing Then If refFileDesc.ReferencedFileType = FileTypeEnum.kAssemblyFileType OrElse refFileDesc.ReferencedFileType = FileTypeEnum.kPartFileType Then Return True End If Else If IsMissingReferencesRecursive(refFileDesc.ReferencedFile.ReferencedFileDescriptors) Then Return True End If Next End Function
However, I've run into a snag. The "ReferenceMissing" property always returns True for Substitute Level of Details. And I can't figure out a way to determine if a FileDescriptor is for a Substitute LOD. If I could, I would just ignore it.
But I'm hoping there's a simpler way. Is there a built-in property that returns whether an assembly is missing references? I couldn't find one but I'm hoping I'm overlooking it.
Or at least a simpler/more reliable way than the one I'm using...
I appreciate any suggestions.