List manipulation, create a vertical element defined by points


#1

Hi there,

I’m trying to create a column mass defined by 2 points which repeats vertically for each floor.

For my 2 point Revit adaptive component to be placed the sequencing of the list needs to be manipulated such that a point needs to be repeated for the next placement.

For example,

1, 2, 2, 3, 3, 4,4,5,5,6…

I’m aware you can use a sweep command however I would like to increase my knowledge with list manipulation and now it’s become personal so I would really appreciate further insight.

If there is a better way to do this then feel free to suggest. However I’m convinced Dynamo has the functionality change the list as requested above so I would be grateful if anyone would like to share.

Many thanks

 


#2

You are looking for the List.Sublists node. See this example, which does what you want it to do. Note that I’m using range expressions, which you can learn more about in the sample files.

Capture

After this, since you want a series of lists with two numbers or points each, make sure you get rid of the last list, which only contains one item. To do this, one trick is to use a code block with a range expression… with the List.Count node called from insidethe range expression. The original list has indices from 0 to 9. Item #9 (which is itself a list with just one item in it) is the item you don’t want, and the total number of items in the list is 10, so by taking the elements of the list from 0 to (10)-2, (same as 0…8 but parametrically linked to the length of the list) you get everything in the list but the last item. Now all of your lists neatly have two elements in them.

Capture


#3

Or alternatively for the last part use the node list.droplastitem from the package manager :wink:

Capture


#4

This is great! I cannot wait to try it out!

I really appreciate your time and efforts. Hats off to both of you. I will let you know how I get on.

 

Thanks!


#5

It worked… Thanks again:)