I finally found some time to look at your part and have re-uploaded it here for you check. Instead of trying to suppress a feature that was in an error state, I instead used a mathematical / logical approach to solving the problem. In fact, here is the code that I used :
If Angle < 0 Then
Angle = 0
End If
If Angle > 90 Then
Angle = 90
End If
Feature.IsActive("Cut1") = Angle > 0 And Angle < 90
What's happening there?
Well first and foremost, I am setting up a minimum and maximum distance that your angle can be. Why? Because going beyond 90 degrees will result in your part being cut into two separate bodies (ew), and everything from 180 ~ 360 (or everything below 0 to -180) is totally unaffected by the cut feature any ways. There's no reason we should let the user input values outside of the 0~90 range, but making a giant table of acceptable ranges is... well... unacceptable. The first two IF/THEN statements keeps our ranges in check.
The LAST line of code is what turns the feature on / off, but we're being a bit clever about it. Instead of writing an IF/THEN statement, I'm basically saying that the Feature's State will = The outcome of the conditional statement 'Angle > 0 And Angle < 90' That means that the Feature.IsActive("Cut1") is only true if Angle is Above 0 AND Below 90. If one of those conditions is isn't true (for instance, your angle is 0) then the cut is turned off.
Here is another way I could have written that
If Angle > 0 Then
If Angle < 90 Then
Feature.IsActive("Cut1") = True
Else
Feature.IsActive("Cut1") = False
End If
Else
Feature.IsActive("Cut1") = False
End If
Pretty big difference huh?
Now, while I understand that your real-world part may be a lot more complicated than the one you gave me, I highly recommend that you do not give up on approaching this from the same vector I did. Just as you would model a part or assembly with your design intent in mind, you often can use those same constraints to logically configure and manipulate the more dynamic aspects of those same models.
If you like how simply this problem was solved, but are unsure whether or not you can apply that same simplicity to a more complicated feature set, please do post more things (or through private message), and I will do my best to find a less API heavy way of solving it.
------
TOTAL SIDE NOTE: When in the hell did Inventor get good at not freaking out when you drove a dimension below 0 using a parameter (or some other math)!? Granted, if you try to open a dim that is below 0, it will still say that it's out of an expected range, but it used to just be a 50:50 chance as to which direction it would go once you increased the value > 0.
Crazy stuff!
**** EDIT ****
Never mind 😞 Further tests show that while it works on the instance of this part (and possibly angles in general), it does not however work for linear dimensions in an expected way 😞 I guess I'll stick to using work geometry offsets as a deterrent. **** it!!!
- The End
If my solution worked or helped you out, please don't forget to hit the kudos button 🙂iLogicCode Injector:
goo.gl/uTT1IB