cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

How to get the value of a parameter in a family table instance with VBA?

cstarnes
12-Amethyst

How to get the value of a parameter in a family table instance with VBA?

I have an Excel sheet that lists all of an assembly's components, and a "Part Number" parameter for each component. My problem is, the parameter isn't read if the component is a sub-assembly, or a part that is an instance of a family table.

Does anyone have an example of how to check if the component is a subassembly or FT instance, and if so...how to get a parameter value from it?

Here is a code snippet of how I'm reading the parameter from every componet (which works if its a part)

    For iCnt = 0 To (pathArray.Count - 1)

            Set eachPath = pathArray.item(iCnt + 1)

            Set mdl = eachPath.Leaf

            ' if model is part

            If mdl.Type = EpfcModelType.EpfcMDL_PART Then

                  iRow = iRow + 1

                  Range("Components").Cells(iRow, colFileName).Value = mdl.Filename

                  

                  Set paramOwner = mdl

                  Set params = paramOwner.ListParams()

                  For i = 1 To (params.Count - 1)

                          ' Get part number and extrusion

                          Set param = params(i)

                          Set paramValue = param.Value

                          Set paramName = param

                          If paramName.Name = "PART_NUMBER" Then

                                  PartNumber = paramValue.StringValue

                                  Range("Components").Cells(iRow, colPartNumber).Value = PartNumber

                                  Exit For

                          End If

                   Next i

               End If

            End If

    Next iCnt


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
ACCEPTED SOLUTION

Accepted Solutions
cstarnes
12-Amethyst
(To:TomasLoun)

The problem was I was starting at index one on a zero-based array (ListParams).

Seems to be working now.

View solution in original post

2 REPLIES 2
TomasLoun
12-Amethyst
(To:cstarnes)

You have there condition

If mdl.Type = EpfcModelType.EpfcMDL_PART Then
so it cannot process nothing else but parts.

What is in the pathArray list? How do you get this list?

Regards,

Tom

cstarnes
12-Amethyst
(To:TomasLoun)

The problem was I was starting at index one on a zero-based array (ListParams).

Seems to be working now.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags