hoe to set ilogic feature.isactive priority

hoe to set ilogic feature.isactive priority

Anonymous
Not applicable
1,027 Views
5 Replies
Message 1 of 6

hoe to set ilogic feature.isactive priority

Anonymous
Not applicable

Hello Experts,

I have a number of rules in a part turning off and on features and changing dimensions. I have the same feature.isactive statement in two different rules and I want one to take priority over the other. if rule one shows feature should be active then it does not matter what the feature.isactive statement says in the second as the first has spoken!

I can create a long winded set of and statements to separate out all of the possible permutations but as the parameters which drive the feature is active have multiple text variables this will become exponentially large.

any help greatly received.

Thanks

Ben

0 Likes
1,028 Views
5 Replies
Replies (5)
Message 2 of 6

blandb
Mentor
Mentor

Can you not set a line that looks at the first is active?

 

such as:

SyntaxEditor Code Snippet

Feature.IsActive("featurename") = True then
do this stuff
else
do this stuff
end if
Autodesk Certified Professional
0 Likes
Message 3 of 6

Anonymous
Not applicable
I don't think so as the second rule is active in all cases.
For instance

1. Is branch a, branch b, or none .isactive
2. Do the branches have leaves on
The result is that because the leave features is on both branches when the second rule runs it turns on the leaves and turns on the branches (because the leaves rely on the branches features to build) regardless of my intent to deactivate the branch if it has leaves or not.
So I want to say rule 1 has priority over rule 2 but I always want to run rule 2 as it effects the branch that is active.
I hope this example clarifies my predicament.
Thanks for your help.
0 Likes
Message 4 of 6

DRoam
Mentor
Mentor

It would help a lot if we could see what your rules are doing.

 

My first reaction is, if rule 2 always runs when rule 1 runs, why not just merge them into one rule so you have better control over how their roles interact with each other?

0 Likes
Message 5 of 6

DRoam
Mentor
Mentor

But if you really need to use separate rules, you could do something like this: as Rule 1 is doing its thing, if it decides a feature should be active, add that feature to a list of "already set" features. Then, when Rule 2 is doing its thing, it can check that list to see if it contains a feature. If it does, it'll skip it, because Rule 1 already set it; if it doesn't, it'll do its own checks.

 

You can use a SharedVariable to pass the list from Rule 1 to Rule 2.

 

That might look something like this:

 

Rule 1:

 

'Create list to hold names of features whose IsActive state has been set by Rule 1
Dim AlreadySet As New List(Of String)

'Checking a feature named Feature1 in Rule1
If SomeCondition = 1 Then
	Feature.IsActive("Feature1") = True
	If Not AlreadySet.Contains("Feature1") Then AlreadySet.Add("Feature1")
Else If SomeCondition = 2 Then
	Feature.IsActive("Feature1") = False
	If Not AlreadySet.Contains("Feature1") Then AlreadySet.Add("Feature1")
Else
	'Don't set the feature, and don't add it to the list.
End If

'Place SetFeatures list in a Shared Variable for passing to Rule 2
SharedVariable("AlreadySet") = AlreadySet

 

Rule 2:

 

'Get list of already-set features from Rule 1
Dim AlreadySet As New List(Of String)
AlreadySet = SharedVariable("AlreadySet")

'Take action based on if Rule 1 already set Feature1's IsActive state
If AlreadySet.Contains("Feature1") Then
	'Rule 1 already set Feature1. Do nothing
Else
	Feature.IsActive("Feature1") = True
End If

'Clear shared list of set features
SharedVariable.Remove("AlreadySet")

 

 

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

yeah this looks like to right method, I'll test this out later in the week and let you know, thanks for your help.

0 Likes