Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all, i've this ilogic macro to set a custom iProp of each ipt in an assembly.
All works fine but i want a control for exist iProp when if exist it add the Part number to an array and at the end show all parts number in a msgbox.
Now it show a windows of each part, how i can show all array list in a same msgbox? Thank you
Sub Main () 'Create variables'set a reference to the assembly component definintion Dim oAssDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim ExcelFullName As String Dim FileName As String Dim ListaEsistenti As New ArrayList Dim oStringList As String Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.InitialDirectory = oOrigRefName oFileDlg.CancelError = True oFileDlg.ShowOpen() If Err.Number <> 0 Then Return ElseIf oFileDlg.FileName <> "" Then ExcelFullName = oFileDlg.FileName End If 'Open Excel database GoExcel.Open(ExcelFullName,"DISTINTA BASE") 'Iterate through each referenced document'Dim oOcc As ComponentOccurrence For Each oDoc As Document In oAssDoc.AllReferencedDocuments ErHa = "Start" Try 'Extract Part Number of active occurrence Dim oPropSet As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties") oPartNumber = Left(oDoc.DisplayName, Len(oDoc.DisplayName) - 4) '(Left(oDoc.DisplayName) -4) oPartNumber1 = oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value ErHa = "Define custom property collection" Parameter.UpdateAfterChange = True i = GoExcel.FindRow(ExcelFullName, "DISTINTA BASE", "Part Number", "=", oPartNumber1) If i = "-1" GoTo PROSSIMO End If Dim COSTO As String = GoExcel.CurrentRowValue("Unit price €") If GetProperty(oPropSet, "Costo").Value Is Nothing Then GetProperty(oPropSet, "Costo").Value = COSTO GetProperty(oPropSet, "Tipo ricambio").Value = "R" GoTo PROSSIMO Else ListaEsistenti.Add(oPartNumber1) End If ErHa = "Update the file" iLogicVb.UpdateWhenDone = True Catch ex As Exception MsgBox("Part: " & oDoc.DisplayName & vbLf & "Code-Part: " & ErHa & vbLf & "Error: " & ex.Message) End Try PROSSIMO: Next For Each oStringList In ListaEsistenti MessageBox.Show(oStringList & vbLf) Next 'Close Excel database GoExcel.Close End Sub Private ErHa As String = vbNullString Function GetProperty(oPropset As PropertySet, iProName As String) As Inventor.Property ErHa = "GetProperty: " & iProName Dim iPro As Inventor.Property Try 'Attempt to get the iProperty from the document iPro = oPropset.Item(iProName) Catch 'Assume error means not found, so create it iPro = oPropset.Add("", iProName) End Try Return iPro End Function
Thank you!
Danilo "DannyGi" G.
Mechanical design engineer and product developer
Mechanical design engineer and product developer
Solved! Go to Solution.