Grasshopper

algorithmic modeling for Rhino

Hello everyone,

 

I encountered one problem when I tried to divide a surface into UV grid.

I do not know how to declare a nested list in GHpython that could store the division points

like in rhinoscript:

arrPts = (USize, VSize)

for i = 0 to UBound(USize)

     for j = 0 to UBound(VSize)

     arrPts(i, j) = rhino.evaluatesurface(srf, paramU, paramV)

 

 

can anyone help to sort it out

here attached is the gh file

 

Thanks a lot

 

peter

 

Views: 1366

Attachments:

Replies to This Discussion

Hi Peter,

 

don'tknow much about python, but if you want to create a nested list structure that Grasshopper can handle, you'll need to create a Grasshopper.DataTree instance and populate that. Grasshopper won't be able to parse a nested list structure.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi Peter,

Here's how it can be done with python.  I made a gist on github since ning is just lame when it comes to displaying code

https://gist.github.com/1272538

 

I've attached an updated version of your definition.

Thanks,

-Steve

Attachments:

 

Thanks a lot, Steve.

I'm going through the code now, but since i'm new to GhPython, might will

have several questions come up later.

 

By the way, is there any method that we can directly apply the python code to grasshopper, without interpretation? 

 

Thanks,

--

Peter

 

 

Hi Peter,

Feel free to ask as many questions as you want; maybe I can even answer a few.

 

By the way, is there any method that we can directly apply the python code to grasshopper, without interpretation?

I don't understand this. What does directly applying the python code to grasshopper mean to you?

 

Thanks,

-Steve

Thanks Steve,

 

I've read through the code, and briefly figured out you were creating the Gh.DataTree in python.

Here is the part of code not quite clear for me:

 

import Rhino

import clr

clr.AddReference("grasshopper")

import Grasshopper as gh

 

sorry for this dumb question, but are these lines above link gh with python?

And what is clr ? I saw this several times in some others' GhPython code.

I know it is the Common Language Runtime, Is it the code could setup the link between python and other programs, i.e grasshopper, processing? 

 

I know how to write Python in Rhino PythonEditor, but am totally new to python in Grasshopper. So if I want to apply Python in GhPython, either I start learning how to link grasshopper with Python, which I don't know how at all at this moment, are there any tutorials about this? Or there is a way GhPython can directly use the Python code I wrote in PythonEditor, which I found out is not always possible in GhPython.

 

 

It isn't a dumb question. This is pretty specialized python code for importing both the RhinoCommon and Grasshopper DLLs so their classes can be accessed in your script. The clr module that is imported has a few functions that allow you to add references to your script (which is similar to how VB.NET and C# use references.)

 

I doubt there are going to be many tutorials at all on writing ghpython component scripts outside of what you see on this forum since the component is still pretty new.

 

If you are running into scripts that you wrote in the python editor which don't run in a component, let me know. That is somewhat of a goal that Giulio and I would like to strive for.

 

Thanks,

-Steve

 

Thank you for this explanation.

Really appreciate what you have done and what you are going to achieve in GhPython. Can't wait seeing the progress! Best luck with it.

 

Actually I was trying to write the code in GhPython  which can divide the surface into isoSurfaces in rectangular or hexagonal shape. Now I am continue with that based on your code. Hope I can work it out.

 

Thanks again for your help

--

Peter

 

Hi Steve,

Here attached is the code which could divide surface into hexagons

Thanks for your help.

 

--

Peter

 

Attachments:

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service