Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic rule not triggering

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
ak_cryo
1870 Views, 9 Replies

iLogic rule not triggering

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.

 

 



Tags (1)
9 REPLIES 9
Message 2 of 10
mdavis22569
in reply to: ak_cryo

I would change Chamfur to Chamfer and try the code again

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

---------
Mike Davis

EESignature

Message 3 of 10
ak_cryo
in reply to: mdavis22569

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.

 

Message 4 of 10
MegaJerk
in reply to: ak_cryo

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.



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 5 of 10
PaulMunford
in reply to: ak_cryo

The rule of thumb is that parameters called directly in your iLogic code will trigger automatically. If they highlight blue in your code, you are good to go!

 


Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin Twitter Instagram Facebook Pinterest

Message 6 of 10
ak_cryo
in reply to: MegaJerk

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!

Message 7 of 10
mrattray
in reply to: ak_cryo

Like MegaJerk, I have a feeling there is a better way to do what you're doing, but it's hard to fully understand your project without seeing the files. Perhaps, some screen captures of the model, the parameters window, and your form(s) would help if you can't upload the whole data set. Also, what is it you're really trying to accomplish with all of this?
I'm not sure it will work very elegantly for you here, but one trick that I use for these sort of things is to Dim a variable and then arbitrarily assign parameters to it. Something like:
Dim trigger
trigger = someParam1
trigger = someParam2
Mike (not Matt) Rattray

Message 8 of 10
ak_cryo
in reply to: mrattray

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.

 

 

 

Form.PNGParameters.PNGPart.PNGFeatures.PNG

Message 9 of 10
mrattray
in reply to: ak_cryo


@ak_cryo 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.

Mike (not Matt) Rattray

Message 10 of 10
ak_cryo
in reply to: mrattray

Thanks Mike, thats just what I needed!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report