Grasshopper

algorithmic modeling for Rhino

Hi. 

I am trying to merge two trees, with each branch consisting of a list of midpoints and endpoints. It is pretty simple to do this in Python, but the output is not as I expected.

How do i write the output, so that I will get a tree consisting of points for further use in GH? I have chosen my input as "Tree access" and my hint as "Dynamic".

Hope anyone has a simple answer. 

Thanks.

Rasmus

Views: 4683

Replies to This Discussion

This is effectively the same question posted here, right?
I've answered it there.

Thanks,

- Giulio
_______________
giulio@mcneel.com

Hi Giulio.

Yes it is. Thanks for your reply, It helped me solve my problem, so that I am running basically my whole routine inside the Python script instead.

I do feel though, that without knowing and being able to use the correct structure between GH and Python, I will not be able to get the full potential. Can you Guilio or anyone else recommend some reading or other things, so that I can get to know these things in depth.

I guess it is about knowing the GH structure in depth and then understanding the transition to and from a Python component.

 

Cheers Rasmus

I'll second the request for some reference material about the grasshopper structures. If not proper documentation, are there header files to look at?

I've gotten some mileage from the typing completion in the C# editor...it will list the methods I can call on a structure, for instance. But anything more comprehensive would be deeply appreciated.

Whoops, that was me, accidentally pretending to be my colleague Arlen...

Hi Rasmus,

my suggestion would be to read a complete Python reference book, if possible with lots of examples. There is no shortcut to knowing how Python (or other languages) work. Please keep on reading because this might help you as well.

---

Hi Dave,

I have the feeling you are inquiring about these two things: (1) what are the types used in the RhinoCommon library and (2) how can I get quick help about their methods?

(2) About getting quick help, I'd agree that the editor could be better. Granted, it is already much better than a simple text editor. I list here some methods to inspect tokens in a script.

  • First of all, you can use the Python dir() function to list all public methods for an object.
  • If you know a type, you can use the alternative syntax to call instance methods in Python, using the type and "self" as first argument.
    Typing "Rhino.Geometry.Vector3d." a window will appear with all methods and properties...
  • Last (this is more a trick but I feel it is sometimes useful) in the GhPython editor you can use the introspection object ghenv, which I take care to add to intellisense every time the script runs. "ghenv.LocalScope." shows all variables that were declared in the local scope last time the script ran. Variables accessed like this link to the last object that was assigned to them, so you get a full list of methods and properties that are available.

I hope this helps,

- Giulio
________________
giulio@mcneel.com

I also forgot: the RhinoCommon library is opensource on GitHub (it is written in C#). And all rhinoscriptsyntax methods are written in Python and you can see them. Please also have a look at these 7 questions with answer about Rhino.Python.

- Giulio
________________
giulio@mcneel.com

Thanks, Giulio! To be clear, I've been writing in C# (simply because old-fashioned procedural C is my "native" language), but was recently struggling with generating tree structures and found this thread.

The RhinoCommon framework is well documented, but I had trouble finding any info about the grasshopper-specific stuff I needed (i.e. GH_Path). The auto-completion in the editor was the best source of info I found, but I'm probably missing something.

Thanks also, by the way, for your excellent C# components, and all-round helpfulness on this forum, I've learned a LOT from your examples.

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