Grasshopper

algorithmic modeling for Rhino

I am wanting to put this script into Grasshopper Python but see it's not as straight forward as I initially thought it would be! Would I have to write an entirely new script or can this one be referenced into Grasshopper Python (with one curve input and one integer input)?

http://designalyze.com/intro-scripting-python-rhino/intro-python-sc...

Thanks for any help!

Dan

Views: 435

Replies to This Discussion

the python script in the tutorial relies on creating polylines in the rhino document, and also relies on user input from the command line.

first, we need to supply the inputs in the python script component. rename your inputs (x and y by default) "crvs" and "num." You should also right-click the "crvs" input and select "list access" because the function expects a list of polylines. 

change these two lines (which get the input via the command line):

count = rs.GetInteger("How many iterations would you like to do?", 3)
pl = rs.GetCurveObject("pick a closed curve to crack")

to this: 

count = num

pl = crvs

 

when you use rhinoscripting in gh python, it creates a virtual rhino document in the scriptcontext object. At the end, in order to harvest the geometry from this virtual rhino document, add this line: 

a = scriptcontext.doc.Objects.Geometries

That should get everything working for you in a GH context.

thank you so much!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service