@formobalaji
Here is a a quick update to @A.Acheson's example.
When I tested his version, my project didn't have a workspace, so this version handles that and uses the project file folder.
This version also closes the opened files, and opens the file with the target part number visibly.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim prjfile As DesignProject = ThisApplication.DesignProjectManager.ActiveDesignProject
Dim prjfolder As String = prjfile.WorkspacePath & "\"
If prjfolder = "\" Then
prjfolder = IO.Path.GetDirectoryName(prjfile.FullFileName)
End If
Dim projectDir As New IO.DirectoryInfo(prjfolder)
Dim workFiles As IEnumerable(Of String)
workFiles = IO.Directory.EnumerateFiles(prjfolder, "*.ipt", 1) '1 searches subfolders, use 0 for top level only
Dim doc As Document
Dim targetdoc As Document
For Each fi In workFiles
doc = ThisApplication.Documents.Open(fi, False)
Logger.Info("File Opened : " & doc.fullfilename)
Try
Dim designProp As PropertySet = doc.PropertySets.Item("Design Tracking Properties")
Dim partNo As String = designProp.Item("Part Number").Value
If partNo = "1234" Then
Logger.Info("Found partNo : " & partNo)
'open visibly
targetdoc = ThisApplication.Documents.Open(fi, True)
End If
Catch ex As Exception
Logger.Info(ex.Message & "-" & "Error Getting Part Number")
End Try
If Not doc Is ThisDoc.Document And Not doc Is targetdoc Then
Logger.Info("File Closed : " & doc.fullfilename)
doc.Close
End If
If Not targetdoc Is Nothing Then Exit Sub ' quit looking for files if target is found
Next
