inventor bug ?

inventor bug ?

Anonymous
Not applicable
420 Views
5 Replies
Message 1 of 6

inventor bug ?

Anonymous
Not applicable

Hi folks

 

I have some code that puts some values from parameters in an arry and sorts them and then uses the middel 2 values to do some calculations.

Now this code works but i have a problem when i run my form that triggers the rules then ilogic repeats some of the rules multiple times .

 

i have three rules the 1st en 2nd are correct but the 3th repeats multiple times and i don't know why.

 

in attachement you can find a screen cast of my problem, my appollogies its in dutch to put my code in english it would take for ever.

 

 

Code 1

SyntaxEditor Code Snippet

If Start= True Then 
           
Dim MyArrayList(3) As Double                    
MyArrayList(0) = X_Afstand_1_Pir
MyArrayList(1) = X_Afstand_2_Pir  
MyArrayList(2) = X_Afstand_3_Pir
MyArrayList(3) = X_Afstand_4_Pir
 
Array.Sort(MyArrayList)                                
For Each Str As Double In MyArrayList

Next 
MessageBox.Show(MyArrayList(1), "Co�rdinaat X1")        
MessageBox.Show(MyArrayList(2), "Co�rdinate X2")    

I1=Abs(MyArrayList(1))/((Binnen_diameter_Pir/2)+Laagdikte_Pir)                                                
J1=(Asin(I1)*180)/3.1415                                                                                     
M1=Abs(MyArrayList(2))/((Binnen_diameter_Pir/2)+Laagdikte_Pir)
N1=(Asin(M1)*180)/3.1415
'Q1=J1+N1 elseif het gene hieronder ?
If MyArrayList(2)<0 And MyArrayList(1)< 0 Then Q1=J1-N1 Else If MyArrayList(2)>0 And MyArrayList(1)> 0 Then Q1=N1-J1
End If
MessageBox.Show(Q1, "Hoek tussen X1 en X2")

 code 2

SyntaxEditor Code Snippet

If Start= True Then 
           
Dim MyArrayList(3) As Double                    
MyArrayList(0) = X_Afstand_1_Pir
MyArrayList(1) = X_Afstand_2_Pir  
MyArrayList(2) = X_Afstand_3_Pir
MyArrayList(3) = X_Afstand_4_Pir
 
Array.Sort(MyArrayList)                                
For Each Str As Double In MyArrayList

Next 
MessageBox.Show(MyArrayList(1), "Co�rdinaat X3")        
MessageBox.Show(MyArrayList(2), "Co�rdinaat X4")    

I1=Abs(MyArrayList(1))/((Binnen_diameter_Pir/2)+Laagdikte_Pir)                                                
J1=(Asin(I1)*180)/3.1415                                                                                     
M1=Abs(MyArrayList(2))/((Binnen_diameter_Pir/2)+Laagdikte_Pir)
N1=(Asin(M1)*180)/3.1415
 Q1=J1+N1
 MessageBox.Show(Q1, "Hoek tussen X3 en X4")        
End If
    

 SyntaxEditor Code Snippet

 If Start= True Then

Dim MyArrayList(3) As Double                    
MyArrayList(0) = Y_Afstand_1_Pir
MyArrayList(1) = Y_Afstand_2_Pir 
MyArrayList(2) = Y_Afstand_3_Pir
MyArrayList(3) = Y_Afstand_4_Pir
 
Array.Sort(MyArrayList)                                
For Each Str As Double In MyArrayList
    
Next 
MessageBox.Show(MyArrayList(1), "Co�rdinaat Y1")        
MessageBox.Show(MyArrayList(2), "Co�rdinaat Y2")    

Hoek_Alpha_Pir=(afstand_tussen_de_trekken*360)/(Binnen_diameter_Pir*3.1415)
MessageBox.Show(Abs(Hoek_Alpha_Pir), "hoek booglengte")    


End If

 

0 Likes
421 Views
5 Replies
Replies (5)
Message 2 of 6

Owner2229
Advisor
Advisor

Well, to stop the rule from running multiple times you can do this:

 

If Start = False Then Exit Sub
Parameter("Start") = False
'... rest of the code
'Don't forget to remove the "End If" at the end of your code
'End If
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 6

Anonymous
Not applicable

how can is use that bit of code so that my other codes still work because now the where i put your solution still works and doesnt repeat anymore but my other codes won't work and thanks for your fast reply

0 Likes
Message 4 of 6

Anonymous
Not applicable

i found a solution for it 😛

 

Would you know why this happens that code repeats its self? Because i never told it to repeat ?

 

0 Likes
Message 5 of 6

Owner2229
Advisor
Advisor

To make the consequent rules run, you can re-enable the "start" parameter:

If Start = False Then Exit Sub
Parameter("Start") = False
'... rest of the code
'Don't forget to remove the "End If" at the end of your code
'End If
Parameter("Start") = True

 

I believe it starts again because you're changing the parameter "Hoek_Alpha_Pir" in your 3th rule, which triggers it.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 6 of 6

Anonymous
Not applicable

the plane for Hoek_Alpha_Pir is plane thats under an angle and the plane for hoek tussen X1 en X2 is just one that is parrallel to my origin plane.

why does the plane for hoek tussen X1 en X2 cause no trouble and the plane under angel does cause trouble?

0 Likes