List filtering - please help me get started

hi all,

Just getting started with Dynamo so please forgive me if these questions are maybe a bit basic!

The challenge I’ve set myself is to rename certain family types based on parameter data. Stage 1 of reading the data from a parameter and then writing it to the name has gone well and generally seems to be working.

However, I also need to be able to read a yes/no parameter and then generate text based on that result. The problems I’m having are as follows;

  1. The generated listed is contains blank values for families where the parameter in question doesn’t exist. How should I go about filtering this list so that it removes these empty fields?

  2. Once filtered I think I then need to map the list to be either true or false - however when I do this based on the value 1 it just makes everything false (here I expected anything that wasn’t 1 to be false and anything that was 1 to be true… )

2015-06-26_10-19-37

 

 

 

 

 

Thanks for any pointers!!

K.

  1. Use the List.Clean node to get rid of null/empty lists

  2. You don’t have to use the List.Map node. Just plug in your Element.GetParameterByName directly into the Equals. If you had sub lists then you would need to Map

Thanks Vikram, will give that a go when I get back to my computer.

1 Like

Hi Vikram, I don’t seem to have a List.clean node - is this in another package?

1 Like

Kieth,

You don’t need any package for it.

However, I’m not sure as to when it was introduced. Why don’t you download one of the recent daily builds. They seem to be quite stable.

Also,empty lists could also be eliminated by flattening. If you don’t want to do so in sub lists and not lose the list structure, you will need to Map and Flatten

 

Okay, found it. However not sure I’m using it right as the list doesn’t change… also even feeding the list directly into the Element.GetParameterByName still isn’t providing expected results - if the string is set to be blank it reports fine - ie the blank fields become true and everything else is false, but if I put in 1 I would expect the last value to be true and the rest to be false - instead everything is false…

Any idea what I’m doing wrong?

2015-06-29_14-14-53

2015-06-29_14-13-57

1 Like

Try feeding in 1 as an integer instead of as a string

aha, excellent, the Equals now works as expected, thanks.

Any my thoughts on the list.Clean not removing the empty fields?

1 Like

You’ll probably need to set preserve indices to false

Sorry, I’m probably being a complete idiot but just not getting this to work.

I’ve disabled the default value and used a string to set the value to ‘false’ (hopefully this is correct) - but the list still shows the empty values…

2015-06-29_16-28-12

 

Keith - Seems like the list is a combination of strings and integers. The blank values being empty strings.

Try something like this…

20150629-3

Brilliant - thank you very much, that has sorted it. Now back to the renaming process!!

Cheers

K.

1 Like

Okay, I’ve messed up. The list filtering worked fine based on that parameter value but I end up with the wrong result because I’ve realised I’m filtering the list at the wrong point.

What I need to do is filter out only the families that I want to change at the very beginning (obvious eh? ;o) ). The Clockwork Node selects all family types of category but what is the best way to go about filtering this list to have only those that have a family name beginning with JMA? I can’t seem to find a node that works like Get Name for elements…

 

 

You can filter the list like this…

 

20150630-2

Ah, now I tried something like that but this is the problem I get here - the list comes up empty.

2015-06-30_13-24-00

 

 

 

 

If I use the Clockwork Node 'All Family Types of Category" it works fine and the rest of the script works exactly as I need it to. I’m curious though how it lists in your example but not in mine.

Thanks again for all your help - I’ve learnt a lot!

1 Like

Just guessing, but the nodes that I’ve used only list out instances of elements used in the project. (I had created a dummy wall and put in some doors in the project file)

All Family Types in Category probably lists out all family types loaded in the project file.

However, the intent of my last post was only to demonstrate filtering. You should be able to employ the concept in your original definition. Right?