Grasshopper

algorithmic modeling for Rhino

Hi,

 

I'm using the python component for grasshopper, and have wondered to access to the data structure which grasshopper consists. 

 

using a=ghdoc seems to be efficient for output, but I can't get the right data structure as input.

 

anything will help.

 

I'm sure that I'm using the latest component(v0.4.1.1)

 

Views: 49141

Replies to This Discussion

I noticed this old discussion, and thought I'd share my current solution:

https://gist.github.com/bengolder/6975370

Hello all,

Figuring out how to properly construct data trees has been a bit of a battle for me over the past year. I often find that generating them in python to be valuable for workflow. 

I came across this explanation and it seems to be the most concise yet. 

very clear and simple, step by step. 

Thanks to those at the COMPUTATION UNIT in advanced design studies at the university of Tokyo. 

check the link below:

http://cu.t-ads.org/?p=399

Hi Guilio.

Is there and overview of functions to call for the DataTree? Like here you mention .AddRange and .Add. Is there some documentation somewhere?

 

If there was a help dropdown list it would be great, but I don't get that.

 

Thanks Rasmus

You get dropdowns when you write a type. Check out signatures by using Python's type.method(self, [args])
syntax for calls. Later you can change it to

self.method([args])
which is more object-oriented.

Also, here you can read about the way to download the Grasshopper SDK.
I hope this helps

Giulio

--

Giulio Piacentino
Piacentino Consulenze

Could you upgrade that file Giulio??

I am quite struggling with the data trees in python but i cannot see your code here  because the component is old and it appears empty

Hi Manuel!

Steve is the maintainer of the GhPython component now. You might want to let him know of this problem. I fixed the script for you, so it will work in Gh 0.9.14 and GhPython 0.5.1.0.

I hope this helps

Giulio

--

Giulio Piacentino
Weaverbird development

Attachments:

Thanks.

Will try not to bother you then with this stuff.

Regards from Barcelona Giulio

Well now and then it's nice to help if I am able to.

Thanks for the greetings, greetings back! :)

Giulio

--

Giulio Piacentino
Weaverbird development

Hi. 

It seems this is the right place to ask this question. I have similar problems. I am trying to merge two data trees, with branches consisting of points. 

I´m getting an output that I can't really use in grasshopper afterwards. (See picture) Any thoughts?

Cheers Rasmus

Attachments:

Hi Rasmus,

just as in the Vb.Net & C# components, you cannot return lists of lists. You need to create DataTree objects explicitly. This is how the Grasshopper SDK works and all scripting components must simply comply to this rule.

I'd suggest, if you can, to use list access or even item access if you can conceive a logic that can only require that. Also, I'd try to dissuade you from replicating the logic for tree components that are already available as this is a slightly hostile territory of the Grasshopper SDK: if you can, use the components that are already available.

Finally, from what I see, you can use item access and this code will suffice:

a = (Midpoint, Endpoint)

I will be on my way to the RhinoDay in Padua, so I might now be able to answer further questions till next week. An example using the internal iteration logic of Grasshopper is attached.

Thanks,

- Giulio
_______________
giulio@mcneel.com

Attachments:

Hi Giulio.

Thanks for answering me. It has been a while now, but I managed to work around the data tree because of your answer. Still thinks that it would be nice to be able to work with the tree structure though.

I can't seem to really use you definition, maybe it was created in earlier versions? :)

Im just curios to see what it is about now...

 

Cheers Rasmus

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service