File vs Document

<?xml encoding=”UTF-8″>By Adam Nagy

Note: this information is from https://github.com/ADN-DevTech/Inventor-Training-Material/tree/master/Module%2014%20-%20Assembly%20Advanced

The File object represents a file on disk and a File can contain multiple Documents. Each Level of Detail corresponds to a specific Document within the same File. All files have a default document so treating a Document as a file on disk will work in most cases.
Document.FullFilename property returns the filename of the file the document is contained within. Document.FullDocumentName property returns a document name which is the filename concatenated with the level of detail name, e.g.

C:TempAssembly1.iam<MyLevelOfDetail>

A special case is the Master level of detail. Supplying or getting back a full document name that consists of only the filename implies the “Master” level of detail:

oAsmDoc = oDocuments.Open(<strong>"C:TempAssembly1.iam"</strong>)
'Is equivalent to:
oAsmDoc = oDocuments.Open(<strong>"C:TempAssembly1.iam<Master>"</strong>)

Filevsdoc

This also explains the difference between Document.ReferencedDocumentDescriptors and Document.File.ReferencedFileDescriptors.
Note: Document.ReferencedFileDescriptors is deprecated/hidden and should not be used, instead use Document.File.ReferencedFileDescriptors

A Document may reference multiple Documents from the same File. So e.g. in case of this Derived Part the following code would provide this result:

Lods

VBA code:

Sub FilesAndDocs()
Dim d As Document
Set d = ThisApplication.ActiveDocument
Debug.Print "ReferencedDocumentDescriptors = " + _
str(d.ReferencedDocumentDescriptors.count)
Debug.Print "File.ReferencedFileDescriptors = " + _
str(d.File.ReferencedFileDescriptors.count)
End Sub

Output:

ReferencedDocumentDescriptors =  2
File.ReferencedFileDescriptors =  1

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading