Efficient Coding, suppressing and unsuppressing features with parameters and rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a more efficient way (processing wise, ease of writing wise, ease of understanding wise) to write this code?
'Reinforcement Kerf Count Left Feature.IsActive("Reinforcement Kerf L 1") = False Feature.IsActive("Reinforcement Kerf L 2") = False
Feature.IsActive("Reinforcement Kerf L 3") = False
Feature.IsActive("Reinforcement Kerf L 4") = False
Feature.IsActive("Reinforcement Kerf L 5") = False
Feature.IsActive("Reinforcement Kerf L 6") = False
If ReinforcementKerfCountL = 1 Then Feature.IsActive("Reinforcement Kerf L 1") = True Else If ReinforcementKerfCountL = 2 Then Feature.IsActive("Reinforcement Kerf L 1") = True Feature.IsActive("Reinforcement Kerf L 2") = True Else If ReinforcementKerfCountL = 3 Then Feature.IsActive("Reinforcement Kerf L 1") = True Feature.IsActive("Reinforcement Kerf L 2") = True Feature.IsActive("Reinforcement Kerf L 3") = True
Else If ReinforcementKerfCountL = 4 Then Feature.IsActive("Reinforcement Kerf L 1") = True Feature.IsActive("Reinforcement Kerf L 2") = True Feature.IsActive("Reinforcement Kerf L 3") = True Feature.IsActive("Reinforcement Kerf L 4") = True Else If ReinforcementKerfCountL = 5 Then Feature.IsActive("Reinforcement Kerf L 1") = True Feature.IsActive("Reinforcement Kerf L 2") = True Feature.IsActive("Reinforcement Kerf L 3") = True Feature.IsActive("Reinforcement Kerf L 4") = True Feature.IsActive("Reinforcement Kerf L 5") = True Else If ReinforcementKerfCountL = 6 Then Feature.IsActive("Reinforcement Kerf L 1") = True Feature.IsActive("Reinforcement Kerf L 2") = True Feature.IsActive("Reinforcement Kerf L 3") = True Feature.IsActive("Reinforcement Kerf L 4") = True Feature.IsActive("Reinforcement Kerf L 5") = True
Feature.IsActive("Reinforcement Kerf L 6") = TrueEnd If
"Reinforcement Kerf '_'" refers to an extrude/cut feature on my part.
I have 6 separate ones at different spacing on the left side of the component
Certain model states need none, some need 3, some need 6, etc.
So instead of manually suppressing and un-suppressing them, I made a multi-value parameter and rule to suppress and unsuppress one or multiple features at once.
On a form I use the option with a radio group:
ReinforcementKerfCountL ~ Reinforcement Kerf Count Left : "0" , "1" , "2" , "3" , "4" , "5" , "6"
When I click a button, it will suppress and unsuppress the 6 cut/extrude features accordingly.
Button "0" suppresses all of them
Button "4" suppresses feature 5 & 6 while unsuppressing features 1-4 so I have 4 cuts on my part
Same for the other buttons
And I notice when I click different buttons the features flash on and off before finally staying steady on or off once it's worked through the code, like it's in a slight loop as it runs the rule.
I'm not the best cod writer at all. So I'm curious if there's a better way of writing what I have.