Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Code not updating properly

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Formsprag
588 Views, 8 Replies

Code not updating properly

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")

8 REPLIES 8
Message 2 of 9
MechMachineMan
in reply to: Formsprag

Order DOES matter when programming.

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2015...

 

 

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")

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 9
Formsprag
in reply to: MechMachineMan

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

Message 4 of 9
MechMachineMan
in reply to: Formsprag

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")

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 9
Formsprag
in reply to: MechMachineMan

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

Message 6 of 9
MechMachineMan
in reply to: Formsprag

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") 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 7 of 9
Formsprag
in reply to: MechMachineMan

Nope, same thing. Both entities update right after the export happens.  

Message 8 of 9
MechMachineMan
in reply to: Formsprag

Try adding 

 

ThisDoc.Document.Rebuild

 

in before the PDF call.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 9 of 9
Formsprag
in reply to: MechMachineMan

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report