Programatically select a component from an assembly in Creo Parametric using VB API
We can programmatically select any component from an assembly using VB API in Creo Parametric. Here the procedure to follow
- Get base session from AsyncConnection
- Get the Current model from the base session
- Convert the model into solid
- List out the solid items and select the components using the index of the component or
- 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