OK, I got a little further in my quest. I cannot, in fact, add anything to the material library and retrieve it via iLogic. What I have done is create an Excel file with the material names and our custom material purchase numbers, and extract the info via iLogic from there.
I'm hitting a snag where some names work fine and some others give me the error: "Conversion of string -Material name here- as type 'Double' is not valid". I have less than 100 entries in Excel today, but I should have upwards of 350 when complete.
The code is very straightforward, the Excel cells are all formatted to "Text", and it does not matter where the material is in the list, it errors out anyway.
I need some help, please 🙂
Code:
FichierExcel = "T:\Inventor Normand\Design Data\iLogic\ListeMateriel.xlsx"
NomMateriel = ThisDoc.Document.ComponentDefinition.Material.Name
For rowPN = 2 To 10000
'Trouve la cellule contenant le Materiel voulu
If (GoExcel.CellValue(FichierExcel, "Feuil1", "A" & rowPN) = NomMateriel) Then
NumMateriel = GoExcel.CellValue(FichierExcel, "Feuil1", "B" & rowPN)
'Save this possibility for later
'Info1 = GoExcel.CellValue("C" & rowPN)
Exit For
End If
Next
InventorVb.DocumentUpdate()
'It just shows the info for now, I'll actually use it later
MessageBox.Show("Nom du materiel: " & NomMateriel & vbLf & _
"Numero du materiel: " & NumMateriel, "iLogic")