- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Most of the time, Inventor is perfectly happy with something like the following:
Dim oAssyDoc As Inventor.AssemblyDocument = ThisDoc.Document Dim oOccurrences As Inventor.ComponentOccurrences = oAssyDoc.ComponentDefinition.Occurrences Dim oOcc As Inventor.ComponentOccurrence Dim oOccDoc As Inventor.Document Dim oCompDef As Inventor.ComponentDefinition For Each oOcc In oOccurrences oOccDoc = oOcc.Definition.Document oCompDef = oOccDoc.ComponentDefinition oParameters = oCompDef.Parameters oBOMStructure = oCompDef.BOMStructure Next
I'm able to create a test assembly that contains sub-assemblies, Parts, AND Sheet Metal parts, and this rule runs without any errors.
However, on some of my real assemblies, I'll get a "Member not found" error on the "oCompDef = oOccDoc.ComponentDefinition" line.
The recommendation on other threads, like this one, is to treat Parts and Assemblies separately, using a PartDocument object for parts and an AssemblyDocument object for assemblies. This, of course, fixes the "Member not found" error. However, it requires literally doubling my code. I don't need to treat assemblies and parts separately; I'm not doing anything that's unique to only parts or assemblies.
Why does doing something like the code above sometimes result in the "Member not found" error, while other times it doesn't? I even have an assembly that will produce the error upon running the code above, but if I do a "Save and Replace Component" on the problem part to replace it with an exact copy of itself, then run the code, the error somehow goes away. Why is this?
What can I do to avoid the error without having to double up my code to handle Parts and Assemblies separately?
Solved! Go to Solution.