Convert String List to Element List


#1

Hello, people!

I’ve been searching a lot for this and haven’t found anything that would fit my needs. I have a list of 13,663 items and each one of them represents a level from the project as strings (and, yes, there are lots of intentional duplicates because each item indicates the level in which a clash was found). The project itself has 28 views(24 FloorPlanViews).

What I need is a way to convert the first list (the one with 13,663 strings) to actual FloorPlanViews. I’ve tried to use “Elements.FilterByName” but the output is a filtered list based on the 28 items list (actual Views). I want the output to be a list of 13,663 View Elements.

 

 

Thanks,

Eduardo Tavares


#2

Hello Eduardo,

First of all, that is a lot of views! You could try using something like “IndexOf” in combination with “List.GetItemAtIndex”, but most likely it will choke with such a long list. I strongly suggest you try creating a dictionary instead.

In the below example I generate a list of random view names, then I use the “Get All Views” node from the archi-lab.net package to get all the views from my project. In the python node, I create a dictionary with the view names as keys and the elements as values. Finally I extract the appropriate element for each random string:

2015-09-22_22-51-50

 

 

 

 

With a dictionary, I manage to convert the 14k strings into elements in just a few seconds.


#3

Hello, Dimitar!

Thanks for your fast help and, yes, it’s a lot of views! I’ve tried your solution and I got stuck at the Python Code with a warning. What might be wrong?

Thanks,

Eduardo Tavares

2015-09-22 12_55_36-Edit Python Script...


#4

Are you sure those strings match the view names inside Revit? It looks like there is not view with that name.


#5

Dimitar,

Always the misspelling… :-s

Thanks, it is working perfectly! I have one last question: I need the output list from your Python Code to be the input on the FamilyInstance.ByPointInView node but I’ve noticed that it expects a single string, not a list. Is there a way to make it accept lists? My intent is to place 13,663 instances of a family type on 13,663 different points and views. That’s why I have a list of 13,663 view variations based on 28 actual views.

Thanks,

Eduardo Tavares

2015-09-22 14_17_41-Dynamo


#6

I got it!

I changed the Python Code inside the “FamilyInstance.ByPointInView” a bit to accept a list of views and got it working. I attached the file if someone else ever needs it too in the future.

Thanks,

Eduardo Tavares

FamilyInstance.ByPointInViewList


#7

Great! I’m glad you made it work. “List.Combine” might have been another option for placing the families on different views. How long did it take to create all of the family instances?


#8

Well, there’s a lot of things that is happening before it creates the family instances and the whole thing takes about 15 minutes to finish. These are are the things it does:

  1. Gets clash data from an Excel file with XYZ, Clash Number,Disciplines affected by the clash and all elevations (for each 13,663 clash from the specific project we are working right now);

  2. Parses the XYZ to a Point and correct its location based on the Survey Point <> Project Base Point

  3. Then it places a “Sphere” family with two parameters fed up by the above Excel;

  4. As I want a 2D (Detail Component) element to be on top of every element on floor plan views, it parses all absolute elevations to their respective levels and then (with your help!) to actual views

  5. Then it places all Detail Components on all views.

Thanks again for all your inputs, Dimitar!

Eduardo Tavares