Grasshopper

algorithmic modeling for Rhino

Associating Properties (whether it's temperature, color, or more) to mesh(es)

I am interested in associating properties to meshes. These properties could be user-defined, for things such as color (represented in a C#' Color object, which is a RGB or ARGB format), temperature (which could be associated to a mesh as a double), and more. 

My question is -- how can one begin to program a component like this? How do I link A (the mesh) to B (a property; any C# object such as ints, doubles, Color, and more) whether it's in VisualStudio/C# or in a Grasshopper definition (which I could see it conceptually, and then convert it to a component)?

I apologize if I am unclear to my goals/objects -- just thinking how an architect would approach this if they were to want to do something like this, which is something I am not.

Additional things I am questioning:

1. Do meshes have associating unique identifiers? For example, I can attach a property to the mesh with the unique identifier mesh10. 

2. What are the C# methods for meshes?

Views: 648

Replies to This Discussion

Hi theGreenCabbage! Have you tried to use .UserDictionary Property? You can attach custom information to the geometry. -Mostapha

Sure! UserDictionary is just a standard dictionary. Here is how you do it in Python:

# You can set it like this

yourMesh.UserDictionary.Set("theKey", "whatEverData")

# And call it back like this

whatEverData = yourMesh.UserDictionary["theKey"]

You can also check Honeybee source code for an example.

https://github.com/mostaphaRoudsari/Honeybee/blob/master/src/Honeyb...

https://github.com/mostaphaRoudsari/Honeybee/blob/master/src/Honeyb...

Out of curiosity -- why can't I find either Ladybug or Honeybee on Food4Rhino?

Long story, short: I don't like Food4Rhino policies. The project is available at: http://www.grasshopper3d.com/group/ladybug

I'd like to know why too.

--

David Rutten

david@mcneel.com

Hi theGreenCabbage and David,

I think Food4Rhino does the job that it is supposed to do. Why Ladybug is not there? It is "me being really picky about how I think the data should be shared."

Food4Rhino has a confirmation process that I want to avoid. I/we update the code very frequently. I usually update the download links as soon as we fix a bug or we make a major modification. In the current workflow it takes two clicks.

It is just so annoying to upload the files each time and wait for someone to confirm your submission once it is ready! I understand that it potentially avoids some issues but I don't want to go through this process every time.

Once, I tried to create a project on food4Rhino with no release which wasn't allowed. You need to have a minimum 1 release to have a project (totally makes sense).

Then I tried to create a release that was basically a python script to tell people that they should download it from another link which wasn't acceptable based on the policies.

There is an option to provide an external link but it should end with .zip, .gha, etc. I'm hosting the files on Box and the link does end with a random string. So I just gave up and removed the project.

----

Moreover I wrote a component that syncs the components (and/or the file) with the gitHub repository so you don't really need to go and download anything anymore! Once you have it downloaded for the first time you just use the component and set the Boolean to True!

Mostapha

this is already included in our [uto] meshedit tools , addattributes, extractattributes if you are interested.

the meshedit tools use the simpler version of the userdictionary Mostapha describes, which is "SetUserString" and "GetUserStrings". See this post for some details on both of these methods. 

Regarding your second point you can look up mesh methods and properties in the RhinoCommon SDK documentation. You'll notice UserDictionary under properties, while SetUserString/GetUserString are under methods. Hope that helps.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service