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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Translate the entire conversation x

VB api to List feature parameters

SC_TK
12-Amethyst

VB api to List feature parameters

Hi, 

 

See the picture here. We often have a feature parameter in an assembly. That can avoid assigning different parameter for the same components in different assemblies. 

Very often we need to change the value of this parameter. I am trying to write a vb.net code to automate the process but cannot find the proper interface, method or function to perform this task. 

Can anyone share a hint? Thanks

SC_TK_0-1747533198581.png

 

ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:SC_TK)

Configure the model item, the owner is the model, the type is a FEATURE, the ID is the feature id, that’s it. The rest of the calls are the same. I guess there a couple of examples for VB. BTW, you still have to configure the tree, in C I don’t know any API to configure the tree display columns.

View solution in original post

2 REPLIES 2
RPN
17-Peridot
17-Peridot
(To:SC_TK)

Configure the model item, the owner is the model, the type is a FEATURE, the ID is the feature id, that’s it. The rest of the calls are the same. I guess there a couple of examples for VB. BTW, you still have to configure the tree, in C I don’t know any API to configure the tree display columns.

SC_TK
12-Amethyst
(To:RPN)

Thanks 17-Peridot,

 

I follow your comments and successfully extract the data.  

In case someone else has the same question as mine, I attached my code here for the reference. 

Thanks again for 17-Peridot 's help. 

        Try
            ' Connect to Creo session
            Dim session As IpfcBaseSession = asyncConnection.Session
            Dim model As IpfcModel = session.CurrentModel

            ' Ensure model is an assembly
            If model Is Nothing OrElse model.Type <> EpfcModelType.EpfcMDL_ASSEMBLY Then
                Console.WriteLine("Please open an assembly in Creo.")
                Return
            End If

            Dim items As IpfcModelItems = CType(model, IpfcModelItemOwner).ListItems(EpfcModelItemType.EpfcITEM_FEATURE)
            Dim i As Integer
            For i = 0 To items.Count - 1
                Dim itemfeature As IpfcFeature = CType(items(i), IpfcFeature)
                If itemfeature.FeatTypeName = "COMPONENT" Then
                    'Console.WriteLine(itemfeature.FeatType & "   " & itemfeature.FeatTypeName & "   " & items(i).Id)
                    Dim featParmOwner As IpfcParameterOwner = CType(itemfeature, IpfcParameterOwner)
                    Dim featParms As IpfcParameters = featParmOwner.ListParams
                    If Not featParms.Count = 0 Then
                        Dim TagParam As IpfcBaseParameter = featParmOwner.GetParam("Tag_Number")
                        If TagParam IsNot Nothing Then
                            Dim TagParamValue = TagParam.Value
                            Console.WriteLine(TagParamValue.StringValue)
                        End If
                    End If
                    'Console.WriteLine(featParms.Count)
                End If
            Next

        Catch ex As Exception
            Console.WriteLine("Error: " & ex.Message)
        End Try




 

Announcements


Top Tags