Hi @dhanshri_gavas. I think you may be looking for the following API paths.
PartComponentDefinition
PartComponentDefinition.ReferenceComponents
ReferenceComponents
ReferenceComponents.ImportedComponents
ImportedComponents
ImportedComponents.CreateDefinition
ImportedComponentDefinition
ImportedComponents.Add
ImportedComponent
And below is an iLogic rule example code including that API object path, and a List(Of String) for holding multiple full path & name Strings for the files you want to import, so that they can very easily iterated through, once filled in. This code example could have also included the use of an Inventor.FileDialog for browsing for those files to import, but I suspect you may already know how to do that part, if needed.
Sub Main
Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
If oPDoc Is Nothing Then
MsgBox("The iLogic rule named '" & iLogicVb.RuleName & "' exited, because no PartDocument was obtained.", vbCritical, "")
Exit Sub
End If
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oImportedComps As Inventor.ImportedComponents = oPDef.ReferenceComponents.ImportedComponents
'<<< specify which files you want to import here >>>
Dim oFilesToImport As New List(Of String)
oFilesToImport.Add("C:\Temp\FileToImport1.stp")
oFilesToImport.Add("C:\Temp\FileToImport2.stp")
oFilesToImport.Add("C:\Temp\FileToImport3.stp")
oFilesToImport.Add("C:\Temp\FileToImport4.stp")
'<<< iterate through those file names and import them >>>
For Each sFileToImport In oFilesToImport
Dim oImportedCompDef As Inventor.ImportedComponentDefinition = Nothing
Try
oImportedCompDef = oImportedComps.CreateDefinition(sFileToImport)
Catch
Logger.Error("Error creating ImportedComponentDefinition from specified file!")
Continue For 'skip to next file name, if any
End Try
If oImportedCompDef Is Nothing Then Continue For 'skip to next file name, if any
Dim oImportedComp As Inventor.ImportedComponent = Nothing
Try
oImportedComp = oImportedComps.Add(oImportedCompDef)
Catch
Logger.Error("Error adding ImportedComponent based on definition from specified file!")
Continue For 'skip to next file name, if any
End Try
Next sFileToImport
oPDoc.Update2(True)
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)