Friday, July 29, 2016

Skewed Grids In Dynamo

Skewed Grids in Dynamo

I start a lot of my work in Dynamo with a rectilinear grid as shown below.  One thing I wanted to do for a while was try to get the grid to skew in such a way that you can get more of a diamond shape as shown in figure 2.  

Figure 1. Rectilinear Grid
Figure 2. Skewed Grid

Not sure why it took me so long to accomplish this because the solution was fairly simply.  All I had to do was replace some of my numbers in my sequence with variables, which were then controlled by a separate sequence themselves.  Let’s break down my original sequence for the original grid.  



In this case, I entered (0..100..10) for my sequence of values and tied this to both the X and Y inputs.  It helps me understand what the code means if I verbalize it like this:  Start with ZERO, stop at ONE HUNDRED, and step up by increments of TEN.  


I must then change the lacing on the Point.ByCoordinatesnode by right clicking on the node and changing the lacing to “Cross Product.”  This gives me a grid of all possible X and Y combinations.  


This is where I got stuck and wasn’t sure how to proceed in order to get my X values to shift by a certain number of units for each row.  This is when I realized that I could replace the values in my original sequence with a variable that was tied to yet another sequence.  This new sequence would then represent the amount of units I wanted my grid to shift for every row.


For now, let’s just add the new code block that has the variable inserted into our original sequence.  You can see above, that I changed the value 0 to (0+X) and I changed 100 to (100+X).  It is worth noting that I am still using our original code block to drive the Y Values.  I should also mention that your script will not work yet until we tell Dynamo what values to use for X.  Another important step is to change the lacing on your Point.ByCoordinates node to Longest.  

We can now tell Dynamo what sequence to use for our new variable, X.  In my case, I not only want the variable to drive the incremental step for each row, but I also want it to drive the stopping point of the new sequence.  I accomplish this by assigning yet another variable to this sequence as shown below, designated with the Letter A:





In the new sequence, I am starting at ZERO, stopping at TEN TIMES A, and stepping up at increments of A.  As a reminder, these new values will be for the new starting point and stopping point of the set of X values for each row.  I can then add a number slider to the input for A.  If I set the MIN to negative 20, MAX to 20, and the step to 1.  This gives me a nice windshield wiper effect as shown below.  




I will admit that this node does have a flaw in that it will not work if set to 0.  But to fix that, you can simply feed the original node back into the X values.  

No comments:

Post a Comment