Delete random items from list?

How can I randomly delete items from a list? I’m trying to remove a set percentage of curtain grids from a grid system - I have a list of all the grids.

So I had already tried something similar to your blog post (but without lunchbox) first to remove every nth item in the list, but something isn’t working right. The run completes but no segments are deleted.


(ignore the random numbers chain down at the bottom, not using it for anything)

Try flattening the list of grid segments?

Flatten between the code block and the remove segment node? Doesn’t seem to work.

after the take every nth :slight_smile: Also take note of lacing in my example on the post

I think this should work well… you can set the percentage of itens on the list that you want to remove.

Still doesn’t work :confused: Also, I don’t see anything about lacing in your post (not exactly sure what lacing entails anyways). I’m fairly new to Dynamo obviously :grin:

I gave this a shot but no results no grids get removed…would it be because my list is of segment curves from the curtain grid, not lines like in your example?

I don’t think so, I thougth it would work for any list, since it does not handle the object type, only index and lists lengths… Have you used exaclty the same nodes and linked them correctly?

Yes, unless I’m missing something I don’t see…I just skipped the code block referring to OriginalList and hooked it straight up to my list.

I guess I missunderstood you on your first question then… Your final list has 155 itens and your original 212, I thought you just wanted to remove those itens on that list as it was actually done…

I’m trying to remove the actual curtain grids to achieve a random spacing on my curtain wall. Removing the items from the list in your method doesn’t remove the actual grids in Revit.

I understand now… I thought it was only about the curves list. Maybe if you use the "curtainGrid.AllsegmentCurves’ flattened by 1 amt (as you’ve done on your first example picture posted here) as the “originalList” of my example, change the last node “RemoveItemAtIndex” to “GetItemAtIndex” and then link this to the node “CurtainGrid.RemoveSegment”, or maybe try the same thing but without changing the “original list”…I actually dont know what node would remove the grids on revit as you said, I work with Advance Steel and I’m not used to work with revit and using grids, but I understand a bit about list management.

I’m close. The last list.flatten in my chain gives me the grid lines I want to delete, but I don’t think the curtaingrid.removesegment node is what I need since I need to remove the whole grid line (and accompanying mullions)…I tried curtainsystem.removegrid but that doesn’t seem to work either. If you’re in advance steel then you probably can’t answer much about curtain walls in dynamo, but thanks for the help!

1 Like

I can’t see your image - can you do a high res export and repost?

If Iam right its bcaz curve is not revit element…!!

1 Like