Hi @jamieking89
Because the parameter names are being read as strings, the lack of leading zeros causes this kind of sorting:
d0
d1
d10
d11
d100
d2
d27
d3
d4
save off a copy of your model to test this code first!!!
Then try pasting this into a new iLogic rule and running it... it should rename all the parameters and put leading zeros as needed ( up to d9999 ). Then the list should sort as expected.
d0000
d0001
d0002
d0003
d0004
d0010
d0011
d0027
d0100
I did a quick test, but use at your own risk .
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oParams = ThisApplication.ActiveDocument.ComponentDefinition.Parameters
If oParams.count > 100 Then
oRun = MessageBox.Show(oParams.count & " parameters detected..." _
& vbLf & vbLf & "This could take a while, do you want to continue?", _
"ilogic", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
End If
If oRun = vbNo Then
Return 'exit rule
End If
Dim i As Integer
For Each oParam In oParams
If Left(oParam.name, 1) = "d" Then
sNumber = Replace(oParam.name, "d", "")
If IsNumeric(sNumber) = True Then
i = sNumber
Else
Continue For
End If
If i < 10 Then
sNumber = "000" + CStr(i)
Else If i < 100 Then
sNumber = "00" + CStr(i)
Else If i < 1000 Then
sNumber = "0" + CStr(i)
Else
sNumber = CStr(i)
End If
oParam.name = "d" & sNumber
End If
Next
MessageBox.Show("Finished formatting parameter names", "iLogic")