One of the very first Dynamo blog posts I read demonstrated how to place an adaptive fence component so that it would follow Topo. At the time, I thought it was an interesting concept, but not overly useful since I typically use non-adaptive fence components and fences will frequently step (instead of slope) with grade change.
However, not all fences are stepped, and I recently decided to take a look at trying the same concept on a non-adaptive fence. It is quite a bit more complicated than the adaptive version, but there are several reasons why you might not use an adaptive fence component and the concept can also be used to place a stepped fence.
To start out, I wanted to be able to create a fence from a set model lines. And I wanted the definition to work regardless of the order the lines were drawn and also if the lines were open or closed, so I created the node Curves.Reorder.
I also wanted to specify the typical fence span/length, divide the lines by that length, and get then get the remaining span at the end. None of the ootb nodes did this, so I created Curve.DivideByLengthRemainders. It also has the option to put the remainder at the end or split it between the start and end.
Both of these nodes are available in today’s Landform update.
The rest of the definition can be broken down into several steps: first it places the fence instance (at its midpoint), then it sets the fence length, then it rotates the fence (to match the angle of the line), and finally it sets the angle of the fence (to follow the topo).
Here it is in full:
The trick to making the last part work (setting the angle parameter) is built into the fence family. In order for the angle to work on both up and down slopes, the angle must be able to be negative. This can be achieved with a few simple control parameters.
If you want to try it out, I’ve uploaded both the Dynamo definition and the Revit fence family (click on the links below to download). Also, the definition only works if the lines are drawn below the Toposurface.
Dynamo (0.9.2): Fence Along Lines.dyn
Revit (2015): Fence – Basic.rfa