Running iLogic rules in order

Running iLogic rules in order

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

Running iLogic rules in order

Anonymous
Not applicable

Hi,

I'm just wondering exactly how rules run in iLogic. I am using the following code:

 

ThisAssembly.BeginManage("Support")

If Support_Type = "A"
		
	Components.Add("Beam", "Support A.ipt")
	Components.Add("Back Plate", "Back Plate.ipt")
	iLogicVb.RunRule("Support A")
	
ElseIf Support_Type = "B"
		
	Components.Add("Beam", "Support B.ipt")
	Components.Add("Flange", "Flange.ipt")
	Components.Add("Channel", "Channel.ipt")	
	iLogicVb.RunRule("Support B")
		
	Patterns.AddRectangular("Flange Pattern", "Flange", Flange_N + 1 ul, Flange_ActP, "Flange", "Pattern Edge")
		
End If

ThisAssembly.EndManage("Support")

 The "Support B" rule outputs the inputs for the rectangular pattern "Flange Pattern", but I always have to run the rule twice for it to update correctly. How do I write my code so the pattern is not made until the "Support B" rule has finished running and the parameters have been updated?

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

CCarreiras
Mentor
Mentor

Hi!

 

Try to update the model before using the pattern.

 

insert this line before the pattern command

InventorVb.DocumentUpdate()

 

CCarreiras

EESignature

0 Likes
Message 3 of 6

Sergio.D.Suárez
Mentor
Mentor

Hello, I have found that in a series of ilogic shortcuts I must execute as your rule twice so that it is actually executed. Then I had to use another form of access or add a loop.
When you execute the rule twice the result is fine?
Do not duplicate the added components?
regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 4 of 6

Anonymous
Not applicable

I have tried document and parameter updates. They don't seem to work.

0 Likes
Message 5 of 6

Anonymous
Not applicable

@Sergio.D.Suárez wrote:

Hello, I have found that in a series of ilogic shortcuts I must execute as your rule twice so that it is actually executed. Then I had to use another form of access or add a loop.
When you execute the rule twice the result is fine?
Do not duplicate the added components?
regards


It does work when I run the rule twice, but is there not a better solution to this?

The added components are different files. They are referred to by the same name, but only one is active at a time.

0 Likes
Message 6 of 6

Sergio.D.Suárez
Mentor
Mentor

It would not be ideal. It would be necessary to study the archives and the accesses to the properties.
However, I think a loop could work like the following

 

For i As Integer = 1 To 2
	MessageBox.Show("Example")
next

Adapted to your problem would be

 

For i As Integer = 1 To 2

	ThisAssembly.BeginManage("Support")

	If Support_Type = "A"
			
		Components.Add("Beam", "Support A.ipt")
		Components.Add("Back Plate", "Back Plate.ipt")
		iLogicVb.RunRule("Support A")
		
	ElseIf Support_Type = "B"
			
		Components.Add("Beam", "Support B.ipt")
		Components.Add("Flange", "Flange.ipt")
		Components.Add("Channel", "Channel.ipt")	
		iLogicVb.RunRule("Support B")
			
		Patterns.AddRectangular("Flange Pattern", "Flange", Flange_N + 1 ul, Flange_ActP, "Flange", "Pattern Edge")
			
	End If

	ThisAssembly.EndManage("Support")

Next

I hope this can help something. regards

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn