Grasshopper

algorithmic modeling for Rhino

Hello,

Currently I am working on a parametric wall design which I fully want to script using python. In order to keep the script visually clear, I want to divide the whole wall in several python scripts (components).

However for the second script to work, the objects (surfaces,points,etc.) from the first script have to be used. My question to you all is how I can connect the scripts to each other, so the objects from the first scripts can be used in the second script.

For instance in the first script I made a surface with the name "Surface1", when in the second script print Surface1 is typed, an error occurs that Surface1 is not defined.

Thanks in advance

Views: 659

Attachments:

Replies to This Discussion

Well, your output from the first python component is 'geometry' not 'Surface1', I would suggest to state in python script number two that 'Surface1' = 'geometry'

The problem is that the output from the first python component 'geometry' is a list of several objects. In the second script I refer to these objects (see image). When I state in the second script that Surface1 = geometry it will give the same error that Surface1 is not defined. Could this error occur that a second script can read a list of objects from a first script?

I thought by simply connecting the Output from the first script to the input of the second that the second script would read the entire list I stated in the first, but that isn't the case unfortunately    

Attachments:

You simply pass along the data from one component to the next using a wire! In your case it seems like the data might be more complex than something that is easily represented by using an item, list or datatree. In such cases you can wrap your data in say a Python dictionary or a class. These data types can be sent through wires (something I suspect a lot of people are not aware of, that can drastically simplify your life!). See the attached example for how one might use classes for this. Note that you can also pass arbitrarily nested Python lists, which is useful for wrapping data to avoid bottlenecks.

Edit: Finally, if you do want to send data "wirelessly" between GHPython components you can use the sticky for this (although I would not recommend this approach unless absolutely necessary).

Attachments:

Yess it works!! Thanks

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