Dynamo and Recursion

So this is what I am trying to do:


The family "ac - bowl - sightline - bowl array" is the container for the seating bowl that I am trying to create. The bowl is built up from steps which are represented by the nested family "ac - bowl - sightline - generator." I want to place instances of this family according to the values I obtain from "E Calc" and "D Calc."


After placing the first step, the new value of E is passed to the equation again, as well as D, and the new results are used to place the next step, etc.


I actually need to have this work in such a way that I can define the overall rise for the grandstand that I want, and the number of risers and it would calculate the risers to fit within these boundaries. Right now I am just going for being able to start at the bottom and work my way up. What this means is that the C value would be constant in this case, while in the final version of the definition I want the C value would vary per riser.


The contants are as follows:


T = tread depth


C = head clearance above head of person in front


E1 = head height of first person from focal point


D1 = horizontal distance to first persons back of seat



The equation is as follows:


D1 / (E1 + C) = D2 / E2


solve for E2


E2 = (E1 + C) (D2) / D1


and then..


E3 = (E2 + C) (D3) / D2


E4 = (E3 + C) (D4) / D3


etc...


Dn is the X coordinate of the family insertion point, En is the Y (or Z) coordinate of the family insertion point.


I actually made a Revit family that accomplishes this, but the problem is that I can't have it create new steps as users specify the number of risers because Revit has no way of autoincrementing a value or feeding the result of one formula to the next instance. So in the family I made I had to build in more steps that necessary (50) and subtract what I did not need using a void. Also I have to add 50 parameters for each variable in the equation so that I could hold the values recursivelly. This meant a family with 500+ parameters.

I've taken a look at the files. It looks like most of your trouble is occurring in the Step Sequence node definition. I can help you with this, I think.



What exactly should this node do? And what do you want/expect it to return as an output?

Ok I tried the above but could not get it to work. I am missing some understanding on exactly where to place the nodes and how to manage the lists.


I have attached the files I am working with. It would be great if you guys could look at them and give me some pointers. Its greatly appreciated.

At this time there isn't such documentation. We will be taking some time soon to update the wiki page on GitHub to document all of the existing nodes.

Soounds good. I will give it a try and report back. :)


I guess one of the difficulties right now is a lack of documentation. Is there a document somewhere that I can download that explains the nodes and their functionality? The samples are great but they are a little too complex for me to understand what each node does and why. Also the use of Python Scripting in the samples clouds the issue a bit for me.


Thanks.

To further elaborate:



All nodes have to return something. In this case, I think you want this node to return all of the modified family instances. This means that you will want to return a list of family instances.



On each recursive call, you want to check if the input list is empty (using the convenient isEmpty? node). If it's empty, then you return an empty list, since you've modified nothing. If it's not empty, then you perform the recursive call by using "cons", which will append an object onto an existing list. In this case, we want to append a modified family instance onto a list of modified family instances. We can modify the first family instance in the list by using the "first" node to grab the first element in the list, and then calculating "C" and setting the appropriate parameter using the "Set Instance Parameter" node. The output of "Set Instance Parameter" will be connected to the "first" input of the "cons" node. The rest of the list should be the rest of the list after it has been processed. In order to process the rest of the last, use the "rest" node to grab the rest of the input list, and pass that into your recursive call.



If you want to save one value and feed it into the next iteration, simply make a new input for the node so that you can pass it along during each recursion.



As Matt mentioned above, a good example to look at is the ConnectPoints node, which recurses through a list of ReferencePoints and draws lines between every two adjacent entries. You can look at it by going to "View>ConnectPoints" in Dynamo, or double clicking the node located in "Revit>ConnectPoints" on the side menu.

Hi Rafael,



You need to look at the sine wave connect points .dyf definition. It has a good example of how to traverse items in lists. If that does not help perhaps you can share your .dyn and .dyf files here?



-matt

Hi Rapheal, have you taken a look at the list nodes? I dont have dynamo up right now but off the top of my head here is how I would approach it: A way to handle this is to pass in the xyz grid as a list into your user node, process the first object in the list as you describe, then pass the list (more specifically the list minus to first item you just dealt with) into the same node recursively. In this way the list will keep getting processed (and keep getting smaller) until all items are processed. You will need an if check check to see if the list contains > 0 items.



We can get you a more detailed answer later if needed.



-matt

Ok, more focused version of the question:


How do I cast an object of type "List" to type "Container"?


I am coming up with a list of distances that I want to cast over instances in an array. How would I do this?