Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Daan_M
344 Views, 7 Replies

Changing iProperties with iLogic

Hi,

 

I'm making a code that allows me to fill existing and create new custom iProperties in batches of partfiles, this infomation comes from an Excel file. Unfortunatly the code does everything correctly except changing the actual properties

 

The code gives the correct iProperty types, names and values (line 52);

Daan_M_0-1699025269053.png

 

But the value of the properties do not change when it runs line 54, no errors occur either.

 

My code (not all of it is important, i think the problem lies in line 54);

 

 

Imports System.Windows.Forms
Sub main
	
Dim rDocs As Documents = ThisApplication.Documents

Dim oFD As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFD)
oFD.InitialDirectory = oOrigRefName
oFD.Filter = "Excel file (*.xlsx)|*.xlsx|"
oFD.CancelError = True
On Error Resume Next
oFD.ShowOpen()
If Err.Number <> 0 Then
Return

ElseIf oFD.FileName <> "" Then
selectedfile = oFD.FileName
End If

Dim oExcel As String = selectedfile

Dim i As Integer = 3

Dim PartFileLoc As String = GoExcel.CellValue(oExcel, "Blad1", "A" & i)

If PartFileLoc = "" Then
	MsgBox("Geen PartFileLoc gevonden in cell: A" & i)
Exit Sub
End If

Do While PartFileLoc <> ""

Dim oPartDoc As PartDocument = rDocs.Open(PartFileLoc, True)
oPartDoc.Activate
Dim n As Integer
Dim nRow As Integer = 2

For n = 1 To 26
	oLetter = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", n, 1)
	oCellAddress = oLetter & nRow
	oCellValue = GoExcel.CellValue(oCellAddress)
	GoExcel.TitleRow = nRow
	oColumnName = GoExcel.CellValue(oLetter & nRow)

If oColumnName <> ""

Dim oProperty As String = oColumnName
Dim oPropertyType As String = GoExcel.CellValue(oLetter & 1)
Dim oSetValue As String = GoExcel.CellValue(oExcel, "Blad1", oLetter & i)
	
	MsgBox(oPartDoc.DisplayName)
	MsgBox(oPropertyType & " & " & oProperty & " = " & oSetValue)
	
iProperties.Value(oPropertyType, oProperty) = oSetValue

End If
Next

i = i + 1
PartFileLoc = GoExcel.CellValue("A" & i)
oPartDoc.Save()
'oPartDoc.Close
Loop
End Sub

 

 

What am i doing wrong?

 

have a good weekend in advance