- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code below has no issue as I have used it for taking value of other iproperties, however for the custom iproperties it cannot detect the corresponding value from the attached file.
Imports System.IO
Imports System.Windows.Forms
Sub Main()
' Get the assembly file path from the user
Dim assemblyFilePath As String = GetFilePath("Select the assembly file", "Assembly Files (*.iam)|*.iam")
If assemblyFilePath = "" Then
MsgBox("No assembly file selected.")
Exit Sub
End If
' Open the selected assembly file
Dim asmDoc As AssemblyDocument = ThisApplication.Documents.Open(assemblyFilePath)
' Define the custom property names to retrieve
Dim propertyNames As String() = {"MARK", "QTY", "SERVICE"}
' Fetch and display each custom iProperty
Dim result As String = "Custom iProperty Values for Assembly:" & vbCrLf
For Each propName As String In propertyNames
Dim value As String = GetiPropertyValue(asmDoc, propName)
result &= propName & ": " & value & vbCrLf
Next
' Show the result to the user
MsgBox(result, MsgBoxStyle.Information, "Custom iProperties")
End Sub
' Function to retrieve the custom iProperty value
Function GetiPropertyValue(oDoc As Document, propertyName As String) As String
Try
Return CStr(iProperties.Value("Custom", propertyName))
Catch ex As Exception
Return "N/A"
End Try
End Function
' Helper function to get file path
Function GetFilePath(prompt As String, filter As String) As String
Dim openFileDialog As New OpenFileDialog()
openFileDialog.Title = prompt
openFileDialog.Filter = filter
If openFileDialog.ShowDialog() = DialogResult.OK Then
Return openFileDialog.FileName
End If
Return ""
End Function
Solved! Go to Solution.