Hi @gharveyMHN58. For one thing...this bit of code won't work:
Dim ofile As PartDocument
ofile = oComp.OccurrencePath
...because a ComponentOccurrence.OccurrencePath returns a ComponentOccurrencesEnumerator object, not a PartDocument object. There are a few ways to get the document that a component is representing. And you usually want to test which type of document it is before trying to assign it to a specific document type variable, but in this case, since were finding the component by name, we already know what type it will be. I fixed that bit of code, and I believe I may have fixed the rest of it as needed to, but I have not tested it, because I don't have your data set to test it on. Give this a try and see if it works for you.
Dim AssemDoc As AssemblyDocument = ThisApplication.ActiveDocument
oAssCompDef = AssemDoc.ComponentDefinition
oComps = oAssCompDef.Occurrences
Dim MyArrayList As New ArrayList
For Each oComp As ComponentOccurrence In oComps 'find the 'piston' component
If Not oComp.Name.Contains("Piston") Then Continue For
Dim oPartDoc As PartDocument = oComp.ReferencedDocumentDescriptor.ReferencedDocument
If oPartDoc.ComponentDefinition.IsModelStateMember Then 'not currently set to "Master"
oPartDoc = oPartDoc.ComponentDefinition.FactoryDocument
End If
oTable = oPartDoc.ComponentDefinition.ModelStates.ModelStateTable
For Each oRow As ModelStateTableRow In oTable.TableRows
Try
MyArrayList.Add(CDbl(oRow.Item("Length").Value))
Catch
End Try
Next
Exit For
Next
MultiValue.List("Length") = MyArrayList
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)