Multiple Translations of varying lengths


#1

Hi everyone,

I am fairly new to dynamo and have had some experience with grasshopper, but I am struggling to get this. It sounded like a simple idea when I drew it out, but I think I am either over complicating it or just totally missing it.

Here is my goal: I am trying to create an object (extruded rectangle/box) that translates across the x-axis at some variable distance from the last object. For example: If I create a rectangle (2x10) I would like to be able to create linear series of these rectangles (along X-axis) with a space between each rectangle that has a random range of space between them. Rectangle 1 and Rectangle 2 would have a random (0-30) distance between them, Rectangle 2 and Rectangle 3 would have a random (0-30) distance etc… Ideally I would like to be able to do this with about 100 rectangles across.

I have made several attempts to do this but I have gotten myself a bit lost in how to construct this in Dynamo. ANY help help is greatly appreciated! Thanks!

Kevin


#2

20150717-1


#3

Vikram,

Thank you for the response! I seem to be missing the ByWidthHeight parameter within Dynamo. It does not recognize it. I am wondering if this is possible to do through a series of nodes? I don’t mind using code to complete the task but I am very unfamiliar with coding. I barely scrape by even with the nodes sometimes haha. I plan to use this as part of a larger script and I think it might help me move forward as I learn more about Dynamo and scripting in general. Thanks again for the help!


#4

Sorry, the script I posted was done in Dynamo Studio (0.8.0)

Change it to ByWidthLength and it will work.

 


#5

Oh I see, thanks! that worked! I am trying to use the nodes built in Dynamo in order to recreate this script but I am struggling with deciphering the script…

Sorry I know this is a simple script.


#6

Hi Kevin,

I’d probably use something like this to replicate Vikram’s example:

2015-07-19_15-03-06


#7

Hi Dimitar,

Thank you for that! that makes more sense to me. I played around with it and i would like to try and create a Vertical portion to this script. I have the series of objects at varying distances between them but, I am wondering how I could create a series of these “object rows” that are evenly spaced apart vertically. Essentially, repeating the script a given number of times in the Z-direction. the catch is that I am trying to do this so that each row has its own random spacing between its respective group members. I don’t want to simply create duplicates of the first row. Is there a way to loop the script a number of times to do this? I imagine if I did, it would only duplicate the first row of objects rather than creating new unique rows. My instinct is to create a number sequence to define the spacing and number of rows i want but I am having trouble working that into the script.

Thanks again for your help!

 

Kevin


#8

Your intuition is right. You could combine the above example into a custom node, replicate the initial geometry vertically and finally apply the new custom node to each item in the vertical list with the help of “List.Map”.

2015-07-20_11-07-17


#9

Thanks Dimitar! I have successfully created the custom node but I am having issues when I connect it to the List.Map node. I get an error that reads “Warning: One or more of the input types are not matching. Couldn’t find a version of __Map that takes arguments of type (__array,__array”. Did I do something wrong in the custom node? It is my first time making a custom node so I wouldn’t be surprised. I have attached the main script and the custom node.

Thanks again, it has been a big help.

Varying Translations Script Custom Node


#10

Hello Kevin,

The “List.Map” node expects a function as an input. To force a node to act as a function, we have to leave one of the inputs unconnected. Notice how in my previous example the “geometry” input was left blank. Try connecting an incomplete node to a watch node and you’ll see that the output is a" _ SingleFunctionObject".

2015-07-21_13-58-59

Right now your custom node is creating a new “Cuboid.ByLengths” at the origin. It would be better if we could make is accept cuboids as an input instead. Try changing it similar to this:

2015-07-21_13-58-47


#11

Hi Dimitar,

 

I have been out for a bit but I got it all working! Thanks so much!

 

Kevin