How to change ipart when i change Multivalue User parameters with iLogic

How to change ipart when i change Multivalue User parameters with iLogic

ikilic1461
Enthusiast Enthusiast
777 Views
9 Replies
Message 1 of 10

How to change ipart when i change Multivalue User parameters with iLogic

ikilic1461
Enthusiast
Enthusiast

Hi;

I want to change  iparts with Multivalue setlist, in Form box. I created 4 multivalues. But, unfortunately, I couldn't run the rule as necessary.

My code as below.  and there are two screenhoots. 

 

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")


If iProperties.Value("Project", "Type-01")  Then 
iPart.ChangeRow("Radiator_study:1", "Type-01")
End If
If iProperties.Value("Project", "Type-02")  Then 
iPart.ChangeRow("Radiator_study:1", "Type-02")
End If
If iProperties.Value("Project", "Type-03")  Then 
iPart.ChangeRow("Radiator_study:1", "Type-03")
End If
If iProperties.Value("Project","Type-04")  Then 
iPart.ChangeRow("Radiator_study:1", "Type-04")
End If
Capture_1.PNGCapture_2.PNG

 

0 Likes
Accepted solutions (1)
778 Views
9 Replies
Replies (9)
Message 2 of 10

A.Acheson
Mentor
Mentor

If you are looking to change the factory members use the below rule. It is different than how you would do this in an assembly. In the factory file the name is left out, where as in the assembly you would normalize the occurrence name first with say “Radiator” then place that as the display name  like
iPart.ChangeRow(“Radiator”, "Type-02")

This way when the member changes the ilogic rule always reference the static name Radiator and not the member name “Type-01:1”

 

Notice the method to use the the parameter “Type”, your data with previous use of the iproperty project with no name of the property like Description, Part Number etc is incorrect.

 

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")


If Type = "Type-01")  Then 
   iPart.ChangeRow("”, "Type-01”)
ElseIf Type = "Type-02”) Then
      iPart.ChangeRow("”, "Type-02")
ElseIf Type = "Type-03”) Then
       iPart.ChangeRow("”, "Type-03")
ElseIf Type = "Type-O4”) Then
      iPart.ChangeRow("”, "Type-04")
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 10

Sergio.D.Suárez
Mentor
Mentor

Hi, I made some changes to your rule as you can see below, I added a button that runs rule 0 to update your model

If Parameter("Type") = "Type-01" Then iPart.ChangeRow("", "Type-01")
If Parameter("Type") = "Type-02" Then iPart.ChangeRow("", "Type-02")
If Parameter("Type") = "Type-03" Then iPart.ChangeRow("", "Type-03")
If Parameter("Type") = "Type-04" Then iPart.ChangeRow("", "Type-04")

 As it is a part file and not an assembly file, note that I have not placed anything in the componentname ""
I hope this helps with your development. Greetings

 

----------------------------------------

Sorry, I had not paid attention to what our colleague wrote before, the code works excellent, you just have to remove the other parentheses it has

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")


If Type = "Type-01" Then 
   iPart.ChangeRow("”, "Type-01”)
ElseIf Type = "Type-02” Then
      iPart.ChangeRow("”"Type-02")
ElseIf Type = "Type-03” Then
       iPart.ChangeRow("”, "Type-03")
ElseIf Type = "Type-O4” Then
      iPart.ChangeRow("”, "Type-04")
End If

 


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

Message 4 of 10

ikilic1461
Enthusiast
Enthusiast

Thank you so much, for your quick reply. 

I couldn't open your part due to my inventor 2018 model . When I copied the code, it worked. But there is only one missing point that Type-04 also must change, like Type-04 i-part. But it doesn't change.

0 Likes
Message 5 of 10

A.Acheson
Mentor
Mentor
Accepted solution

Oh No! My mistake I made a few typos in the first post I put there thanks @Sergio.D.Suárez , tried to copy and paste on the cell phone and didn't test it. I left a few typos in for someone to figure it out. 😂 This one works I promise. But can you guess where the typo was, answers on a post card!!

 

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")


If Type = "Type-01" Then 
   iPart.ChangeRow("", "Type-01")
ElseIf Type = "Type-02" Then
      iPart.ChangeRow("", "Type-02")
ElseIf Type = "Type-03" Then
       iPart.ChangeRow("", "Type-03")
ElseIf Type = "Type-04" Then
     iPart.ChangeRow("", "Type-04")
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 6 of 10

ikilic1461
Enthusiast
Enthusiast

Thanks a lot for your help, it worked successfully. 

0 Likes
Message 7 of 10

ikilic1461
Enthusiast
Enthusiast

I also have a problem with below issue;

When I do "No" to "Joint_flange_"  , Joint flange must disappear in Type-03 and Type-04. 

It is successful in Type-04, but i can not understand why it is not working in Type-03.

Here is my codes , and ipt documents. 

My inventor version 2018. If some changes need in rule , may you write as code. Capture3.PNG

 

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")
MultiValue.SetList("Joint_flange_", "No", "Yes")
If Type = "Type-01" Then 
   iPart.ChangeRow("", "Type-01")
ElseIf Type = "Type-02" Then
      iPart.ChangeRow("", "Type-02")
ElseIf Type = "Type-03" Then
       iPart.ChangeRow("", "Type-03")
ElseIf Type = "Type-04" Then
     iPart.ChangeRow("", "Type-04")
End If
If Type = "Type-01" Or Type = "Type-02” Then
Feature.IsActive("Sweep3") = False
Feature.IsActive("Extrusion25") = False
Feature.IsActive("Sweep4") = False
Feature.IsActive("Split1") = False
Feature.IsActive("Split2") = False
Feature.IsActive("Revolution1") = False
Feature.IsActive("Revolution2") = False
Feature.IsActive("Extrusion28") = False
ElseIf Type = "Type-03" Or Type = "Type-04” And Joint_flange_ = "Yes" Then
Feature.IsActive("Sweep3") = True
Feature.IsActive("Extrusion25") = True
Feature.IsActive("Sweep4") = True
Feature.IsActive("Split1") = True
Feature.IsActive("Split2") = True
Feature.IsActive("Revolution1") = True
Feature.IsActive("Revolution2") = True
Feature.IsActive("Extrusion28") = True 
ElseIf  Type = "Type-03" Or Type = "Type-04” And Joint_flange_ = "No" Then
Feature.IsActive("Sweep3") = True
Feature.IsActive("Extrusion25") = True
Feature.IsActive("Sweep4") = True
Feature.IsActive("Split1") = False
Feature.IsActive("Split2") = False
Feature.IsActive("Revolution1") = False
Feature.IsActive("Revolution2") = False
Feature.IsActive("Extrusion28") = False
End If 
iLogicVb.RunRule("Rule0")

 

0 Likes
Message 8 of 10

A.Acheson
Mentor
Mentor

I believe this is the issue, if you are trying to activate ElseIf @ (1)  Param "No"  and Param "Type-03" what is happening

is it is defaulting to ElseIf @ (2) (first one reached) and running down through the if statement bypassing the Or and subsequent And statement and hence always keeping the flange active for Param "Type-03"

 

AAcheson_2-1631161681764.png

 

 

Working Rule:

MultiValue.SetList("Type", "Type-01", "Type-02", "Type-03", "Type-04")
MultiValue.SetList("Joint_flange_", "No", "Yes")

If Type = "Type-01" Then 
	iPart.ChangeRow("", "Type-01")
ElseIf Type = "Type-02" Then
	iPart.ChangeRow("", "Type-02")
ElseIf Type = "Type-03" Then
	iPart.ChangeRow("", "Type-03")
ElseIf Type = "Type-04" Then
	iPart.ChangeRow("", "Type-04")
End If
InventorVb.DocumentUpdate(False)

If Type = "Type-01" Or Type = "Type-02” Then
	Feature.IsActive("Sweep3") = False
	Feature.IsActive("Extrusion25") = False
	Feature.IsActive("Sweep4") = False
	Feature.IsActive("Split1") = False
	Feature.IsActive("Split2") = False
	Feature.IsActive("Revolution1") = False
	Feature.IsActive("Revolution2") = False
	Feature.IsActive("Extrusion28") = False
ElseIf (Type = "Type-03" And Joint_flange_ = "Yes")  Or (Type = "Type-04” And Joint_flange_ = "Yes") Then
	Feature.IsActive("Sweep3") = True
	Feature.IsActive("Extrusion25") = True
	Feature.IsActive("Sweep4") = True
	Feature.IsActive("Split1") = True
	Feature.IsActive("Split2") = True
	Feature.IsActive("Revolution1") = True
	Feature.IsActive("Revolution2") = True
	Feature.IsActive("Extrusion28") = True 
ElseIf  (Type = "Type-03" And Joint_flange_ = "No") Or (Type = "Type-04” And Joint_flange_ = "No")Then
	Feature.IsActive("Sweep3") = True
	Feature.IsActive("Extrusion25") = True
	Feature.IsActive("Sweep4") = True
	Feature.IsActive("Split1") = False
	Feature.IsActive("Split2") = False
	Feature.IsActive("Revolution1") = False
	Feature.IsActive("Revolution2") = False
	Feature.IsActive("Extrusion28") = False
End If 
iLogicVb.RunRule("Rule0")

Further to that the rule is taking 30 seconds to 1 minute to switch members and switch flange to No/Yes using ilogic  This could be an excel issue and you may or may not be seeing it your end. If you add the flange suppression as a new key member in the iPart table, the time to switched a member  reduces to 15  seconds. This is about the same time to switch between members.  

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 9 of 10

ikilic1461
Enthusiast
Enthusiast

Thank you. You are the king 😊

0 Likes
Message 10 of 10

A.Acheson
Mentor
Mentor

AAcheson_0-1631208481734.png

In case you were wondering, I had typed the Letter"O" instead of zero. it is perfectly obvious here where the zero gets a dash through it, but the ilogic editor doesn't display the letter "O" much differently than a zero apart from the subtle size change. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes