I am currently writing my first dynamo script but I am not getting anywhere, even with videos on youtube.
Below is my situation:
I have a host family with 9 nested families. I have a model where this host-family appears in different combinations with these 9 nested families. I have added a custom parameter “RLadder” in this host-family. This is based on the 10R model to increase circularity in construction. Each element in my model can have a score different in this 10R model. I want to assign a color to each score (from 1 to 10) via a Dynamo script so I can see at a glance which element gets which score on the R-Ladder.
I used this youtube video to set up the script but at the last 2 nodes I get the following error message:
List.GetItemAtIndex operation failder. Index was out of range. Must be non-negative.
and
Element.OverrideColorInview operation failed.
If this explanation of the situation is not clear I will be happy to provide more information.
Sounds like you don’t have the same number of items each time.
Index out of range means you’re looking for item number 6 (for example) when you’ve only got 4 items in your list.
You need to write in a count so this doesn’t happen…
Sounds like quite an ambitious script for a first go though.
Maybe do a few simpler ones first so you get the basics?
Not sure I understand the structure of your model, but an export of your graph’s workspace with node previews expanded would help.
After zooming in so your node names are clearly legible use the “export as image” feature in the top right hand corner (or the camera icon in older builds) to save the entire canvas as a png, and post that here or on a 3rd party site such as dropbox, google drive, box, onedrive, etc…
Zoom in so a single node can be clearly read before you do the export. Also expand the data previews for both nodes leading into the first node with a warning so we can see what type of data you’re working with and what the structure is.
The 250 elements are a listing of all nested families in my model. I give the host family in the model the classification on the R ladder and it links them into the nested families of this type.
Ok, now I see what is going on. you hav ea list of lists of true/false values, and you’re looking for the index of true in that list of lists. You likely want to look though each sublist directly. Set the node circled in red to use @L2 as the list input.
That said, you’re likely going to get some odd values. Instead of using a List.GetItemAtIndex a dictionary would be more effective here. I’ll try and put a sample together before I leave the office…
So i’ve changed the input to L2, and indeed, i got some weird values. Strange thing is that some of the elements in my model get colored already, but not all of them
The solution via dictionary will be much more efficient as mentioned by Mr. Jacob and will dispense you with a nice number of spaghetti and the string to number node
Cordially
christian.stan
With a few minutes to spare, I built a Sandbox solution so you can look at the concepts and decipher how to implement them in the context of your project.
Hi Jacob. I am trying to understand the graph and build your example but I don’t see the connection with my elements. I build a graph based on your example and it runs without warnings but nothing seems to happen in my model.
This is because there isn’t one. As I don’t have your Revit model I can’t build something in that context. I did try to put annotations into the group to explain how things relate to your workflow, but effectively:
Where I generate points, you want to get your Revit elements somehow.
Where I pull the Z value, you want to get the parameter value for ‘RLadder’.
Where I list numbers as strings, you want to list the possible parameter values of ‘RLadder’.
Where I have 4 colors, you want a color for each ‘RLadder’ value.
Where I build a dictionary, you should do the same.
Where I get the value from the dictionary, you should do the same.
Where I change the color, you want to use an OverrideColorInView
If you post a sample model and a .dyn showing an attempt at building the stuff above then I can step in to help more directly. If you are unable to post to the forum directly, you can utilize a 3rd party service such as Dropbox, GoogleDrive, OneDrive, etc…
Didn’t have an RLadder value on the family you had in the file, so I copied a few of them around and added values of “A”, “B”, “C”, or “D” to each. This graph worked fine for me from there. The original graph I posted is above, with the changes below.
Having done this I can’t help but notice that a better workflow (and Revit native) would be to utilize a filter on the view, as that would update in real time and this will not.