mandag 26. oktober 2015

Ammo: Replication Guides for (semi-)Dummies

I'll for one admit it. These replication guides are useable, but not very understandable.. I get the basics they teach you over at Dynamo primer and in the designscript manual, but I see Dynamites use these for much more complicated things all the time and I wonder how they figure it out..

Well, this has got to end, right?

So the post today is mostly for my own sake. Hopefully, though, someothers can also pick it up and use it to get what these suckers is all about. I will also update the post as time goes by and additional knowledge is acquired.

Just some terminology I'm gonne use first of all. I'm going to name my list levels tier 1, tier 2, tier 3 etc. this corresponds with the number inside the replication guides. If I want a object to get in the tier 2 of a list, then I would have to use the <2> guide.
Secondly just by using replication guides it means that I will pair all of the values of the lists I'm providing, like crosslacing with ordinary nodes, but now I can choose how to group them as well!


EDIT: It has just been brought to my attention that one can use an "L" inside the angle brackets to make the replication guide utilize the "longest" lacing option. Like this: Point.ByCoordinates(x<1L>,y<1L,0)

Let's start with an example:

The Points:

So here we want to draw some points based on simple one dimensional lists for X, Y and Z-values. That will be lists that got only items in Tier 1.

This is the standard result without any replication guides added.

Observe that this works just like a standard Point.ByCoordinates node with lacing set to short where the point function takes the first item in each list, creates a point, then the second item in each list, creates a point and so on.

Now, if we add a <1> behind the x in our codeblock it means that the list of X's will be put in the Tier 1 of our resulting list. But there is not entered any replication guides for Y and Z so Dynamo can't quite figure out what to do. In other words it threats Y and Z values with lacing set to short, it only takes the first item in the Y and Z lists and pair it with each of the X-values.

If we now want all the the Y-values to be in the resulting list as well, considering the Tier 1 is already composed of all the X-values, we chose to put all the Y-values in Tier 2 using the <2> guide.
Observe that we now have a grid, since we've paired all of the X and Y-values. Since Dynamo still isn't told what to do with the Z-values, it takes only the first Z-value into consideration.
If we now want all the Z-values to be included, and Tier 1 and Tier 2 is taken, we say to Dynamo that we want the Z-values at Tier 3, using the <3> guide.

Understandable?
I think many people comes this far and find it ok(ish), but what about when we start to use this on other lists containing not only numbers but different kinds of data?

We'll have a look at another example:

The Translated Points:
Ok, so I start off with a list of three lines. I want to produce two points on each line, at parameter 0.2 and at parameter 0.8.

Just a digression:
The PointAtParameter node is an action node, so I can't type
Curve.PointAtParameter(curvevariable, parametervariable)
the "curvevariable" is put to the front as the object I'm doing something with. Like this:
curvevariable.PointAtParameter(parametervariable)

This applies to most action nodes! If I where to explain the DS syntax of most action nodes , this is my best go:



Digression End.

Now I have to choose how I will Tier my resulting list. In this example Tier 1 will be my lines (Use <1> behind the crv) and Tier 2 will be my parameters (Use <2> behind the param). Observe that this is like grouping! Will I group by lines or group by parameters?


And here is just an example of where I've grouped the list by parameters instead. Notice I switched the guides.


Now lets make this even worse. I want to use the points I've created and translate each of them two times i Z-direction. Of course I could have just duplicated the translate node with different vector input in each, but with replication guides you don't have to.

Setup:

Dynamo won't know what to do here cause my points are grouped by lines (nested list) and my vectors is also in lists.
I we want to conserve the grouping by curves and points we have to "pay homage" to its list structure by including its Tiers in the replication guides. The variable geom has to be followed by <1><2>, this way the result list starts with the points list original Tiers. If we then guide the translation vectors into Tier 3, we're all set.


See? Now we have maintained the grouping of data from the beginning until the end. If I pick index 0 from our first list of lines, then picking index 0 of the last codeblock corresponds to that! I will get the 4 translated points for the first curve.

Next up I want to add the first points I created to the list with the translated points. List.Create? No, sir!

(First of all, notice that the most of the List action nodes is not like the rest. Here you have the arguments inside the paranthesis like an ordinary create node.)

Now, what do I want to do here? I want to take each of the first list's Tier 2 and add it to the second list's Tier 2. Take the input lists structure into account, and you'll get this:

So pretty neat this replication guide, eh?

There is still many mysteries to me how replication guides works, but the above summarize what my simple mind think when I use them. If it sometimes doesn't work, I start with the above and just try various combination until it works. It obviously helps a lot if you know what your output list should look like.
 Be careful with replication guides and Revit nodes, though.. If you mess it up, you're going to have RAM-issues pretty quickly, you are hereby warned...
Hopefully, someday, someone can explain the logic in full detail and so simple that anybody can understand it! And please let me know if some of the logic above is utterly wrong.

lørdag 10. oktober 2015

Ammo: Sheet piles with Revit and Dynamo

I'm gonna show you a quite useful workflow in this post that utilize Revit and Dynamo to produce a sheet pile wall extended to a toposurface with a variable top level.

There are of course many ways to approach this, the workflow I'll show you is this:

1. Top of sheet piling is drawn by model lines in the project.(Clockwise or Anticlockwise)
2. A topography for reference top terrain
3. A topography that will drive the bottom of the sheet pile.
3. Select the model lines and lowest surface.
4. Dynamo magic! (and replication guides... lots and lots of them..)

The family I'm using here is a hosted adaptive component.

The hosted component: 2pt adaptive component
1. Create two AC-points underneath eachother in a new family.
2. Draw a sheet pile profile on the first point's horizontal plane.
3. Select the two points and create a spline.
4. Change the spline and change it to a reference line in the properties.
5. Select the reference line and the closed profile and hit create form.
6. Check that the point number two change the depth of the form.
7. Load in to the next family.


The rig: 3pt adaptive component
1. Create two adaptive points on the same level in a new family
2. Select the two points and create a spline between them, later changing it to a reference line.
3. Make the first point's vertical plane the active workplane and place a point on the first adaptive point.
4. Drag the point downwards a bit and make it adaptive. (So it becomes the third adaptive point.)
5. Set workplane to the reference line's horizontal plane.
6. Click Create>Component and place the component's first point so that it snaps to the workplane of the referenceplane. (you may have to tab a little bit..)
7. the second point of the component you snap to the Rig's third point. (are you still following??)
8. Observe that by changing the Rig's second point's position, you rotate the hosted component.
9. select "Always Vertical" in the properties.
10. If you want to report the height of the family you can create a reporting parameter between the first and third point.
11. Load into project


The Script: Replication guides heaven
I chose to show a condensed version of this script this time, and the reason are the powerful replication guides. I feel like I'm starting to get hold of these buggers and maybe I will create a blogpost about them in near future. Shortly put, if you ever need to use List.Combine or multiple List.Map nodes, you're easier of, in terms of screen estate, using replication guides.

Often, Sheet piles will close of a building site and to keep things simple I suggest that you draw all your model lines either clockwise or anti-clockwise. this way you will not have to worry about which way the sheet piles are turned. (I'm sure, however, that this is doable given some time and some imperative code). I'v included a simple -1 or 1 for direction in the script depending on whether you drawn them clockwise/anti-clockwise


Count on your PC having to work a bit with this. in the example provided, it took about 7 minutes to create all 1230 generic models.

A particular useful thing about this script is that you can split the model lines where you observe that it is to low compared to the terrain and then change the workplane so that the lines are optimal. I guess a further study would include projecting the lines to the top terrain as well with an offset.

A little youtube video showing a more uncondensed version: Youtube