List ''Jitter'' node

is there some list shuffle function like Jitter in Grasshopper ? Explanation of Jitter component - Grasshopper - McNeel Forum
For now I use Python scrip I found but it is no reliable for large lists and does not work as expected.

items = IN[0]
percent = IN[1]

def jitter(items,percent):
    n = len(items)
    m = (n**2 * log(n))
    items = items[:]
    indices = list(range(n-1))
    for i in range(int(percent*m)):
        j = choice(indices)
        items[j],items[j+1] = items[j+1],items[j]
    return items

OUT = jitter(items,percent)

I tried to replicate the jitter function from that link- Explanation of Jitter component - Grasshopper - McNeel Forum but I am very bad at python. It kind of works, but the control of jitter is not what it is in original GH node. Maybe someone could fix the code…

# Load the Python Standard and DesignScript Libraries
import sys
import clr
import random
import decimal
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
List = IN[0]
Jitter = IN[1]
Seed = IN[2]
# Place your code below this line

def jitter(items,percent):
    n = len(items)
    NewKeys= []
    for i in range(n):
        rangeStart = i-percent
        rangeEnd = i+percent
        number = round(random.uniform(rangeStart,rangeEnd),2)
    sortedList = [items for _,items in sorted(zip(NewKeys,items))]
    return sortedList

# Assign your output to the OUT variable.
OUT = jitter(List, Jitter)

Using just Dynamo nodes, it seems possible. (I’m not a big grasshopper user so this node is new to me, but it looks/sounds awesome!)



Graph Image:

Jitter.dyn (24.8 KB)


@john_pierson Yeah, I think you did the same as I in pyton :). The difference between GH and this Jitter is that Strength range in GH is decimals from 0…1 I wonder if that changes anything

Oh interesting. Yeah you can definitely tie that slide to those values or even do a mapto on that R input as well.

Great solution @john_pierson. :slight_smile:

Had no clue this was a thing in grasshopper before this afternoon. I’ve used a Python based method for this on a recent project, the code for which is as follows:

import random
baseList = IN[0]
offsetFactor = IN[1]
offsetLimit = len(baseList) * offsetFactor
key = [] 
for i in range(len(baseList)):
   offset = random.random() * offsetLimit
   sortedVal = i + offset
newList = [ i for _, i in sorted(zip(key,baseList)) ]
OUT = newList

@solamour this might be a useful node to add.


I’d say the Dynamo team should give Grasshopper a spin - heaps of awesome ideas there that could serve an equally useful purpose in Dynamo as well. Even quick/basic nodes for working with geometry more quickly like deconstruct point/vector/plane and domain assessment might be handy.

1 Like

Much of the actual Dev team have ample GH experience, and while I am not on the Dynamo team I do lurk on their forums from time to time.

There is a lot of learning to be had in both directions. As users we should try to be aware of ALL THE PLATFORMS as that’s the best way to grow.


Awesome - I figured there was likely a lot of cross learning happening already, plenty of features we’d love on opposite sides of the fence (lists vs trees anyone?). Not sure if the team is aware but GH2 is also out and looks very interesting, if a fair way off still. Having said that I’m very stoked with many of the new features and changes in Dynamo as well.

1 Like

already got inspiration for new features for monocle. :sunglasses: