Hi,
I have set a number of true/false parameters which control whether corresponding features are suppressed or not.
e.g. FeatureEnable1 (True/False) controls Hole:1, Extrusion:1 and Chamfur:1
FeatureEnable2 (True/False) controls Hole:2, Extrusion:2 and Chamfur:2 etc.
The iLogic rule uses a while loop to cut down on the amount of code. E.g.
While i <= 15 If Parameter("FeatureEnable"&i) = True Then
Feature.IsActive("Hole:"&i)=True Feature.IsActive("Extrusion:"&i)=True
Feature.IsActive("Chamfur:"&i)=True
Else
Feature.IsActive("Hole:"&i)=False Feature.IsActive("Extrusion:"&i)=False Feature.IsActive("Chamfur:"&i)=False
End If i = i+1 End While
The rule works when activated manually. However it is not activated automatically when the parameters FeatureEnableX are changed.
I previously had the ilogic set up without the while loop and it ran automatically when any FeatureEnableX parameter changed. This makes me think the ilogic rule doesn't know what parameters to watch to change as they are not explicity refered to. Is there anyway to manually set the rule to run when a user defined parameter changes.
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
My bad spelling strikes again! Thanks, but that was just some pseudocode to try and explain my problem. My actual code is:
Dim i = "1" While i <= 15 If Parameter("InnerTap"&i) = True Then Feature.IsActive("InnerTap:"&i)=True Feature.IsActive("Wiring_slot_inner:"&i)=True If Parameter("IGrooveTop"&i) = True Then Feature.IsActive("Wiring_groove_top_inner:"&i)=True Feature.IsActive("Wiring_groove_bottom_inner:"&i)=False Else Feature.IsActive("Wiring_groove_top_inner:"&i)=False Feature.IsActive("Wiring_groove_bottom_inner:"&i)=True End If Else Feature.IsActive("InnerTap:"&i)=False Feature.IsActive("Wiring_slot_inner:"&i)=False Feature.IsActive("Wiring_groove_top_inner:"&i)=False Feature.IsActive("Wiring_groove_bottom_inner:"&i)=False End If i = i+1 End While
It works fine when it run it manually (right click -> Run Rule) i.e there are no spelling mistakes/errors in the code. However I would like it to trigger automatically when the True/False parameters InnerTap1, InnerTap2, etc. are changed.
I previously had the code set up to address each of the 15 occurances individually and the rule did trigger automatically. However the code quickly became unmanageable.
Sadly if there isn’t a direct call to consume or use an Inventor parameter (that isn’t nested or obscured behind outright VB code), it does not seem to trigger the rule to run. This also means that if there is an event trigger set to run the rule, it is ignored (which is bad)! The only way to do what you’d like to do would be to use a goofy work around like creating an arbitrary parameter that gets updated in order to force your rule to run.
Something like:
MyInventorParameter = MyInventorParameter
(MyInventorParameter being a unit less parameter)
It’s not ideal, as you would have to update that value before your rule ran, which is tedious and defeats automation.
A really super insane and crazy way of writing everything out with the fewest lines of code possible (that I could come up with) is as follows :
Feature.IsActive("InnerTap:1") = InnerTap1 * -1 Feature.IsActive("Wiring_slot_inner:1") = InnerTap1 * -1 Feature.IsActive("Wiring_groove_top_inner:1") = (InnerTap1 * -1) * (IGrooveTop1 * -1) Feature.IsActive("Wiring_groove_bottom_inner:1") = (InnerTap1 * -1) - (Feature.IsActive("Wiring_groove_top_inner:1") * -1)
Of course, as I’m sure you noticed, that only applies to 1 of 15 of your feature sets. Not hard to copy / paste, but still not ideal.
I would be interested in experimenting with your part file if you’re able to upload it without causing someone to accuse of trying to corporate espionage. Perhaps there is means of designing it differently so that this looping work-around is moot.
Hi MegaJerk, Thanks for your reply.
Your suggested code is similar to what I originally had. I changed it to a while loop as it became a tedious excercise to update the code when a new feature was added.
I am currently working round the problem by using two buttons on the form that takes input parameters. One button is the standard apply button, which needs to be pressed first to update parameters. The other is a button to manually run the associated rule. This is the most user friendly solution I could come up with at the moment. Ideally it would be nice to combine both buttons, but I haven't managed to find a way to do this yet.
I'm not sure quite what the situation is on sending you the part file, I will try to find out. I wouldn't see it being a problem but will leave it for the moment.
My next problem is looking for a way to speed up the code, (un)surpressing the number of features referenced in the code can sometimes take upwards of 2 minutes!
Thanks for replying Mike.
I have included a few pictures below. Let me try and explain how the part works:
I have three different iFeatures: Wiring_Slot, Wiring_Groove_Top and Wiring_Groove_Bottom
Each iFeature has 15 instances. Whether these are suppressed or not depends on True/False parameters. The user accesses these parameters using the form.
My iLogic code then watches the True/False parameters and suppresses/unsuppresses features when required.
However because my code doesn't explicitly reference the parameters the iLogic rule doesn't get automatically triggered.
Currently I have to press the 'Apply' button on the form to change the parameters on the part, then press the 'Apply Changes' button to run my ilogic rule. It would be preferable to do this in one button press.
I hope I explained this OK, if you have any more questions I'll do my bext to answer them.
@Anonymous wrote:
Currently I have to press the 'Apply' button on the form to change the parameters on the part, then press the 'Apply Changes' button to run my ilogic rule. It would be preferable to do this in one button press.
Well, that statement makes me think that a solution may be far easier than I was thinking. You can, inside the form editor, control the behaviour of the ilogic button that you named "Apply Changes". There is a drop down selector within its properties window under "Behaviour" called "On Click Action". Set it to "Apply and then Run Rule" or "Apply and then Close and then Run Rule" as you prefer.