how to iterate through all occurrences (suppressed and unsuppressed all included at the same time) under an assembly?

how to iterate through all occurrences (suppressed and unsuppressed all included at the same time) under an assembly?

junGQMXK
Enthusiast Enthusiast
412 Views
2 Replies
Message 1 of 3

how to iterate through all occurrences (suppressed and unsuppressed all included at the same time) under an assembly?

junGQMXK
Enthusiast
Enthusiast

hi, everyone,

 

recently, I met a situation where I needed to iterate through occurrences(suppressed ones and unsuppressed ones) under an assembly. I need to know all the components (names, part numbers....) of the assembly.

 

I tried to use occurrences, allreferenceddocuments, and even browsernodes. but they are all used for "unsuppressed" components. when dealing with a "suppressed" component, these methods do not work at all(they failed especially when dealing with suppressed components under subassemblies).

 

anybody knows how to iterate through "suppressed" components to collect component information?

 

any ideas or suggestions are appreciated.

 

thanks in advance.

 

 

 

0 Likes
Accepted solutions (1)
413 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @junGQMXK.  That is definitely a tough situation.  When all instances of assembly components that reference a specific file are suppressed, they will be unloaded from Inventor's memory, and will not be listed in the referenced documents list.  If a top level component is suppressed, we can still find it, but we can not do much with it in that state, so accessing its sub components is very difficult, if not impossible.

 

What you may need to use instead of components or referenced documents is referenced Files (or referenced FileDescriptors).  An Inventor File is different than an Inventor Document.  A File is just a File on disk, but a Document is the data from a file that has been partially or fully loaded into Inventor's memory.  Plus, a single File can have multiple Documents defined within it, if it has multiple ModelStates defined within it (one Document per ModelState).  For the same reason, you can have way more referenced Documents in an assembly than referenced Files.  When iterating File or FileDescriptor objects, you may want to do so one level at a time, using a recursive method, instead of attempting to get a single collection of all referenced File or FileDescriptor objects directly from the top File.

 

Edit:  Just to add to that...the difference between File.AllReferencedFiles and File.ReferencedFiles is that the first one will attempt to get all of them at all levels below it, while the second will just get the directly referenced ones only.  Same with AllReferencedDocuments and ReferencedDocuments.  And the File.ReferencedFileDescriptors property, similarly only gets the direct ones.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

junGQMXK
Enthusiast
Enthusiast

hi,  WCrihfield,

 

thank you very much for your suggestions. your analysis and conclusion are very important to me in helping me avoid unnecessary efforts to do the iterations.

 

I will try to use "files" to do the iteration.

 

 

0 Likes