algorithmic modeling for Rhino
Hi all
I am trying to recreate a jitter in python. I have checked the python random module in the help, however I am not familiar with the distributions mentioned. So could be an easy fix - if it is existing.
I hate to say it - but i'm trying to implement a jitter for a glazing pattern in Dynamo :(
I would like to caveat that by saying that I find every single aspect of Dynamo inferior to Grasshopper, both functionally and most annoyingly aesthetically. The whole deal pisses me off, however, it is what it is.
I had produced some layouts by exporting a flat dwg of an elevation and writing a GH script to produce some design options, but in order to implement these, I'm faced with manually selecting panels and changing them according to essentially a GH generated picture. Changing these natively would obviously be preferable.
I have written some code to work out a glazing percentage and number of items (per level), then work out a repeating module of True and False values, then multiply this list to match the desired length of items (i then cheat and just append true and false to match list lengths)
However i now need to try to jitter - I did think to check rhinocommon (in fairness i searched for it in the command line to discover this is not a native rhino command and assumed it wouldn't exist in rhinocommon - so perhaps schoolboy error)
anyway code is attached, any help would be much appreciated.
(I have also asked on stack overflow - if anyone as this issue further down the line)
http://stackoverflow.com/questions/41969036/varying-degree-of-shuff...
Apologies again
I ♥ David , Rhino and McNeel
Tags:
oh trying to re-upload def
added some blank lines for easy reading
Try this - given a list L, a seed S, and a Jitter factor J between 0,1, it should behave a lot like the grasshopper native jitter:
import random
J = min(1.0,J)
J = max(0.0,J)
maxDist = J*len(L)
random.seed(S)
sortArray = []
#create sort array for each item
for i in range(len(L)):
minVal = max(i-maxDist,0)
maxVal = min(i+maxDist,len(L))
item = random.uniform(minVal,maxVal)
sortArray.append(item)
a = [val for (sort,val) in sorted(zip(sortArray,L))]
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by