- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
to search a part based on partnumber
iam looking for an ilogic to open the part from a project location base on its partnumber
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can type the partnumber in the searchbox in the Inventor Assembly browser. No code needed....
https://youtu.be/kequNEtPE9A?si=4J15aBB94XNsSIbw
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @formobalaji
Maybe something like this would work. This rule will expect to find a part number "1234" in a part file in the project folder. This rule is untested so you might find errors. Post back with the error messages on the more info tab.
Dim prjfolder As String = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath & "\")
Dim projectDir As New IO.DirectoryInfo(prjfolder)
Dim workFiles As String() = projectDir.GetFiles("*.ipt")
Dim doc As Document
For Each fi As String In workFiles
doc = ThisApplication.Documents.Open(fi,False)
Try
Dim designProp As PropertySet = invDoc.PropertySets.Item("Design Tracking Properties")
Dim partNo as String = designProp.Item|("Part Number").Value
If partNo = "1234" Then
Logger.Info("Found partNo : " & partNo,)
End If
Catch ex as Exception
Logger.Info(ex & "-" & "Error Getting Part Number",)
End Try
Next
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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