Delete all except selected outcome from multi-value parameter

Delete all except selected outcome from multi-value parameter

david.tunnard
Enthusiast Enthusiast
177 Views
1 Reply
Message 1 of 2

Delete all except selected outcome from multi-value parameter

david.tunnard
Enthusiast
Enthusiast

Hi all,

 

Im hoping this should be failry simple.

 

I have a multi-value list which has, for example, 'Part A', 'Part B', and 'Part C'

 

If Part A is chosen then it gets added to the assembly, I would then want to delete the other two options from the assembly (if they are in it).

 

At the minute I am just doing a variant of the following:

If example = "Part A" Then

	Dim componentA = Components.Add("Part A", "Part A.ipt")
	Components.Delete("Part B")
	Components.Delete("Part C")
	
End If

 Is there a better way to do this?

0 Likes
178 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

Hi @david.tunnard 

If your using a multivalue parameter then this is an arraylist, see ilogic help page here . So what you can do is loop through this arraylist like so and do something with the string value. 

For each val As String in MultiValue.List(“example”)

    If example = "Part A" Then

	    Dim componentA = Components.Add("Part A", "Part A.ipt")
	
     Else 
        Components.Delete(val)	
     End If

Next

 

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