Searching in List on multiple attributes

Hi all,

I am struggling with the following problem. I have a list of 50 points, which have the attributes Material, Width and Length. I want to make a structure based on a parts list. This list consists of structures with a specific Material, Width and Length. See

Unfortunately this returns a list with 4 items all joined together (probably to be expected from String.Join)

Any ideas on how to get this working properly?

Thanks in advance

Hi @Nindooo ,
Do you want to join Material, Width and Length in one line, like the Part Size list? See if this is what you want.

"Put "+ x +" "+ y +" x "+ z;

str = "Put ";
x;
y;
z;
[Imperative]
{
	result = [];
	j = 0;
	for(i in GetKeys(x))
	{
		if (x[i]!="")
		{
			result[j] = str+x[i]+" "+y[i]+" x "+z[i];
			j = j+1;
		}
		else
			continue;
	}
	return = result;
};
1 Like

Yes that works! Thankyou very much. However, another problem occured. In one list it is written as 1.500 and in the other one it is written as 1500 without the dot. Is there an easy way to remove one or add it to the other?

What kind of data there is in the list? Just string? or do you have integer and double as well?
Assuming that 1.500 is a string, otherwise it would show as 1.5 in the list, you can “clean” the dots before feeding the node for concatenating the strings.

1

Unfortunately it is not of type string. I get the following error with string.replace:

Warning: String.Replace expects argument type(s) (string, string, string), but was called with (Autodesk.Civil.DynamoNodes.PipeNetworks.PartSize, string, string).

I was able to fix it with String from Object. The replace is now working correctly. However, i am stuck at the next step. List.GetItemAtIndex is not working because the joined part is not an index. GetItemByName doesn’t work either because the Partslist is not a ListDefinition.

Any idea?

Please if it is possible attach an image of your problem it will help a lot.

I tried both of the following things:


Maybe you need a get all indices of node, not get item at index?

Hi @Nindooo in your first image it looks like you need an “element name” before feed in "index of…

Try to check if it same object type and names match…

Thank you very much, this worked!

1 Like