I have a piece of code that’s not updating properly and I can’t figure out why, I was wondering if someone could tell me what's happening?
Here’s what it’s doing: Clutch_Size updates every time perfectly, Oil_Volume updates to the previous setting when the rule is ran. So basically they are not in lock step with each other. I need both parameters to update together every time.
iProperties.Value("Custom", "Clutch_Size") = Parameter("Clutch_Size")
iProperties.Value("Custom", "Oil_Volume") = Parameter("Oil_Volume")
If Clutch_Size = "1M" Then
Oil_Volume = "7"
End If
If Clutch_Size = "2M" Then
Oil_Volume = "12"
End If
If Clutch_Size = "4M" Then
Oil_Volume = "15"
End If
If Clutch_Size = "8M" Then
Oil_Volume = "22"
End If
If Clutch_Size = "12M" Then
Oil_Volume = "30"
End If
If Clutch_Size = "18M" Then
Oil_Volume = "50"
End If
If Clutch_Size = "30M" Then
Oil_Volume = "65"
End If
If Clutch_Size = "42M" Then
Oil_Volume = "80"
End If
If Clutch_Size = "60M" Then
Oil_Volume = "110"
End If
InventorVb.DocumentUpdate()
Parameter.UpdateAfterChange = True
MultiValue.UpdateAfterChange = True
iLogicVb.RunExternalRule("Export to PDF")
Solved! Go to Solution.
Solved by Formsprag. Go to Solution.
Order DOES matter when programming.
Parameter.UpdateAfterChange = True MultiValue.UpdateAfterChange = True Select Case Parameter("Clutch_Size")
Case "1M" Parameter("Oil_Volume") = "7" Case "2M" Parameter("Oil_Volume") = "12" Case "4M" Parameter("Oil_Volume") = "15" Case "8M" Parameter("Oil_Volume") = "22" Case "12M" Parameter("Oil_Volume") = "30" Case "18M" Parameter("Oil_Volume") = "50" Case "30M" Parameter("Oil_Volume") = "65" Case "42M" Parameter("Oil_Volume") = "80" Case "60M" Parameter("Oil_Volume") = "110" End Select InventorVb.DocumentUpdate() iProperties.Value("Custom", "Oil_Volume") = Parameter("Oil_Volume") iProperties.Value("Custom", "Clutch_Size") = Parameter("Clutch_Size") iLogicVb.RunExternalRule("Export to PDF")
Still the same thing, I set the clutch size and nothing happens the first time I run the rule. I change the clutch size and now the drawing updates to the first setting. However now both the clutch size and oil volume are lock step together just one update behind.
Thanks
There are a couple lines you could have tried as in the link posted.
And seeing as you have the data in 2 locations, "not updating" isn't very helpful.
You should be telling us whether it's the parameter, iProperty, or both that aren't updating.
Anyhow, give this revised version a whirl and report back.
Parameter.UpdateAfterChange = True MultiValue.UpdateAfterChange = True
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True Select Case Parameter("Clutch_Size") Case "1M" Parameter("Oil_Volume") = "7" Case "2M" Parameter("Oil_Volume") = "12" Case "4M" Parameter("Oil_Volume") = "15" Case "8M" Parameter("Oil_Volume") = "22" Case "12M" Parameter("Oil_Volume") = "30" Case "18M" Parameter("Oil_Volume") = "50" Case "30M" Parameter("Oil_Volume") = "65" Case "42M" Parameter("Oil_Volume") = "80" Case "60M" Parameter("Oil_Volume") = "110" End Select iProperties.Value("Custom", "Oil_Volume") = Parameter("Oil_Volume") iProperties.Value("Custom", "Clutch_Size") = Parameter("Clutch_Size") iLogicVb.RunExternalRule("Export to PDF")
Sorry for not being clear before.
Now both the parameter and the iProperty update together but they both do so after the file has been exported to the PDF format. I we could get this update to happen before the export to PDF it would be perfect.
Thanks
That would be cause by the fact I swapped the update to after the entire rule finishes.. I should have left it to update at that set point, as it was before.
Parameter.UpdateAfterChange = True MultiValue.UpdateAfterChange = True RuleParametersOutput() Select Case Parameter("Clutch_Size") Case "1M" Parameter("Oil_Volume") = "7" Case "2M" Parameter("Oil_Volume") = "12" Case "4M" Parameter("Oil_Volume") = "15" Case "8M" Parameter("Oil_Volume") = "22" Case "12M" Parameter("Oil_Volume") = "30" Case "18M" Parameter("Oil_Volume") = "50" Case "30M" Parameter("Oil_Volume") = "65" Case "42M" Parameter("Oil_Volume") = "80" Case "60M" Parameter("Oil_Volume") = "110" End Select iProperties.Value("Custom", "Oil_Volume") = Parameter("Oil_Volume") iProperties.Value("Custom", "Clutch_Size") = Parameter("Clutch_Size")
InventorVb.DocumentUpdate()
iLogicVb.RunExternalRule("Export to PDF")
Try adding
ThisDoc.Document.Rebuild
in before the PDF call.
Got it, here's what I did:
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 13177 StartFragment: 314 EndFragment: 13145 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
Parameter.UpdateAfterChange = True MultiValue.UpdateAfterChange = True RuleParametersOutput() Select Case Parameter("Clutch_Size") Case "1M" Parameter("Oil_Volume") = "7" Case "2M" Parameter("Oil_Volume") = "12" Case "4M" Parameter("Oil_Volume") = "15" Case "8M" Parameter("Oil_Volume") = "22" Case "12M" Parameter("Oil_Volume") = "30" Case "18M" Parameter("Oil_Volume") = "50" Case "30M" Parameter("Oil_Volume") = "65" Case "42M" Parameter("Oil_Volume") = "80" Case "60M" Parameter("Oil_Volume") = "110" End Select InventorVb.DocumentUpdate() iProperties.Value("Custom", "Oil_Volume") = Parameter("Oil_Volume") iProperties.Value("Custom", "Clutch_Size") = Parameter("Clutch_Size") iLogicVb.UpdateWhenDone = True InventorVb.DocumentUpdate() iLogicVb.RunExternalRule("Export to PDF")
Can't find what you're looking for? Ask the community or share your knowledge.