algorithmic modeling for Rhino
import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp
from math import*
x = 0
y = 1
num = 0
for i in range(0,10):
num = x + y
x = y
y = y + num
num = num + 0
print num
You have probably at some point created a list by the name of range. GHPython component caches the variables. Copy-past the component and your code should run.
Thank you my code ran. Yes I did create a range from gh components to feed into for loop earlier...i think it stores those variables...
It does. Also your code will look more "pythonic" and will run faster if you make couple of minor changes.
for i in xrange(0, 10):
num, x = x + y, y
y += num
print num
thank you I am very new to scripting....I tried this code for generating Fibonacci series numbers...but that logic did not work ..hehe
And I did not get y you added X in front of range
Hi Gaurav,
with the range function you'll create a list and then will iterate through all the values in the list. With xrange, you directly generate values one by one. range will also work in this case. But xrange is more pythonic as Mostapha said.
-Devang
Thanks devang for information. I am an Architect with degree in parametrics but programming is not my forte. Though gh visual programming is something I have developed a good hand on. Its hard for being creative and at the same time worry about command or codes. But to advance in parametric I have to learn to code. I saw your videos of solar shading and form optimization, you seem to expertise coding. Little advice would help me go further. Thank you !
Hi Gaurav,
I am sincerely happy to learn that you aim to take up coding. I think of programming as a design tool. I am assuming that you would like to use Python as the vehicle to begin your journey in the world of programming. With that assumption, I would recommend following resources;
1. thenewboston
2. Think Python
3. Codecademy Python course
4. MIT OCW
I would like to offer an analogy here to make a point as to why learning to code is important for anyone regardless of profession or industry. It is my observation that packaged software tend to influence problem-solving methods. For instance, if one's using excel for data analysis, there's a good chance that excel will influence one's problem-solving approach. One will only think about running analysis that is possible in excel. If we let a packaged software influence our inquiry, that's not good in my opinion.
So I think of packaged software as packaged food. We can't have it all the time. At some point, we need to learn to cook. That's programming.
Learning to code will also make it very easy for you to work with the best minds in the world. So keep doing a little bit at a time and you will pick it up very soon.
I am no expert by any measure. But I would highly recommend following people like Mostapha. He was also trained as an architect in Iran. With his work, he has made a tremendous contribution to this industry(Read - "Changed the world").
Hope this helps.
Best,
-Devang
You're welcome Gaurav! I took a glace at your page. Impressive portfolio there. With this type of solid focus on parametric geometrical explorations and 3D printing, I believe you should connect with following folks;
Thanks,
-Devang
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by