admin@creocustomization.com

Programatically select a component from an assembly in Creo Parametric using VB API

Programatically select a component from an assembly in Creo Parametric using VB API

programmatically select a component from an assembly in creo using vb api

We can programmatically select any component from an assembly using VB API in Creo Parametric. Here the procedure to follow

  1. Get base session from AsyncConnection
  2. Get the Current model from the base session
  3. Convert the model into solid
  4. List out the solid items and select the components using the index of the component or
  5. Select the component by its name

Sample Code 

' Import Libraries
Public AConnection As IpfcAsyncConnection
Public BSession As IpfcBaseSession

Private Sub btn_SelectionFromString(sender As Object, e As RoutedEventArgs)
    Try
        BSession = AConnection.Session
        Model = BSession.CurrentModel
        Dim ISolid As IpfcSolid = CType(Model, IpfcSolid)
        Dim MItems As IpfcModelItems = ISolid.ListItems(25)
        Dim CMSelect As New CMpfcSelect
        Dim ISelection As IpfcSelection
        ISelection = CMSelect.CreateSelectionFromString("123454321.prt")

    Catch ex As Exception
        MessageBox.Show(ex.ToString, "Failure")
    End Try
End Sub

Leave a Reply

Contact Us