View name shows with ID number and one with no ID - how to fix?

Hi,

I’m trying to filter list of views and the output I get comes without ID (I assume that’s what this green number is). I tested Schedule formatting against my output of filtering and simple View output. The latter gives me effect I want but my initial output doesn’t. What am I missing here?

Hi,

I suspect the one with no ID is a string, whereas the one with the ID is the actual Revit element. Hard to tell without the complete graph, but that’s my guess :slight_smile:

Here is my dyn file. Yes, it is a string… but then - how to “recall” the actual element? It’s like my third day with Dynamo and I assume I do some obvious mistakes.

schedule width.dyn (33.7 KB)

I only use Dynamo 2.0 so I can’t open your graph… Just join a screenshot with the preview of each node, that will be enough.

I have had a look at the graph you have uploaded and at the beginning you are converting the schedules to strings by “String from Object”. This converts them into strings which removes the ID of the object. You may need this for your filtering, but your result element is not a schedule anymore.

What you need to do is when you want to filter the schedule list, feed it into the list of the “List.FilterByBoolMask” node, not the list of strings. Follow this for the rest of the filtering and the output will get the actual schedule with the ID.

2 Likes

Thank you, that worked! Although it skewed the result of the list somehow (list.sort doesn’t do the job as I’d like it). So another question - how do I filter the list so I can only show views starting from a specific character ? I tried to use startswith node but honestly wasn’t lucky with that.

Can you show how it didn’t work?

You would need a String from Object node first and then when you filterbybool, the list input should be the original element list, like before.

This is just a wild guess but if you tried to use StartsWith to find views that started with a number, make the number into a string using “09” as the searchFor input.

It tells the input doesn’t match but as I see on your sshot it looks the same (list as input)? Or does it mean that elements on the list aren’t strings and thus they should be converted ? But then when I set input as converted list I get more errors down the pipe…

image

image

p.s.

I basically need to get rid of every element from the list that does not start with number. And since all the elements I need start with 0 I used startswith with “0” as input and then was thinking about getting the inverse selection (or so do I understand IN/OUT output.

p.p.s.

Also tried String as input instead of code block

First of, the List.Filter should be List.FilterByBoolMask. Try that and tell me what happens.

To see if the String.StartsWith works, check its output, it should be all True or Falses.

Secondly, you are trying to filter a list that was already filtered with the String.Contains node, yet the bool mask is using all of the original list of views. So the input lengths will not line up or match in length.

1 Like

Ok, I see I’m making a big mess here, but simple things first. Why does the String.StartsWith produce all false results? Tried with string and code block as input (does it matter?)

image

String and code block are the same, except if you use a string node, you need to remove the " " around it. To see what’s wrong, check the output of the Object to String node and see what you are getting.

I am pretty sure your problem is that you are not getting the view name, but the view object, which is different. Use an Element.Name node or something similar and then feed that into the String.StartsWith node.

1 Like

You have to make sure that you are always starting with a list of schedules and then convert those into strings.

If you take it step by step and begin every group of filtering with the output of the FilterByBoolMask.

You are connecting nodes from previous filters along the graph and it is confusing Dynamo!

Just group them step by step and start with a nice neat output of a list of schedules.

1 Like

I tried to clean this mess a little and still Startswith gives me all false result, so the input seems wrong.

Yeah, your problem was that you used the View object into string, instead you need the View name.
tostringView

Feed Element.Name directly into the string startswith or string.contains.

Thank you guys! It worked! Lesson here - do everything by small step and watch what happens with information along the way!

1 Like

Going beyong initial question - could the filtering here be done in one go? Ie use a && b && c to filter the list (or rather filter one list by another)?

That is great glad it worked out.
if you always break things down into groups of (input query output) and then start again with the output, it generally keeps you out of trouble.

There is always more elegant ways of solving the problem, but sometimes being able to follow it step by step gives you a better understanding of how Dynamo manages the lists.

1 Like

With enough ifs, anything is possible.
lotsofIfs

!String.Contains(x,test1,false) &&
!String.Contains(x,test2,false) &&
String.StartsWith(x,testFor,false)?true:false;
1 Like