Hi @tmathieson
ok that helped me see the issue... my test file was just cramming some values into the thickness and length parameters, so I wasn't seeing the issue with those numbers not updating.
So your original code was using
"BPFGL" + CStr(PLATE_TH_MM * 10) + CStr(PLATE_LENGTH) + "N"
changing the parameters from this format:
PLATE_TH_MM
to this format, seems to do the trick
Parameter(PLATE_TH_MM)
I'm not exactly sure why changing it from a dynamic syntax to a static syntax made a difference here, but that appears to be the case
Also I changed the + to & and then Cstr wasn't needed
One more thing that might help is to use the iLogic Log rather than message boxes to return the values... it's just a faster way to debug, see this link for how to turn that on and use it:
To Create Log Statements | Inventor 2019 | Autodesk Knowledge Network
You're doing fine with the programming part of it, some of this stuff is just not real clear in ilogic because of the lack of a proper debugger
Give this version a try and post back if you're still seeing issues.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition
Dim oStates As ModelStates
oStates = oDef.ModelStates
Dim oTable As ModelStateTable
oTable = oStates.ModelStateTable
'get the current model state, so we can return to it when done
oCurrentState = ThisDoc.ActiveModelState
' Iterate All Rows of model states
i = 1
Dim oRow As ModelStateTableRow
For Each oRow In oTable.TableRows
'this activates the row to make it the current state
oStates.Item(i).Activate
'get the current parameter values
oTK = Parameter("PLATE_TH_MM") * 10
oLN = Parameter("PLATE_LENGTH")
'set the default PN
oPN = "BPFGL" & oTK & oLN & "N"
'append the value with X if the feature is active
If Feature.IsActive("HALF-PLATE-CUT") = True Then
iProperties.Value("Project", "Part Number") = oPN + "X"
Else
iProperties.Value("Project", "Part Number") = oPN
End If
'set ID to match PN
iProperties.Value("Custom", "PART_ID") = iProperties.Value("Project", "Part Number")
oMsg1 = "Model State: " & oStates.Item(i).Name
oMsg2 = "Part Number: " & iProperties.Value("Project", "Part Number")
Logger.Info(oMsg1)
Logger.Info(oMsg2)
Logger.Info("----------------------")
'MessageBox.Show(oMsg1 & vbLf & oMsg2)
i=i+1
Next
'set original state active again
oStates.Item(oCurrentState).Activate
