Grasshopper

algorithmic modeling for Rhino

When I try to convert string to GH_String and then append to a tree, the tree returns <empty>, when it's supposed to return "something". I think I made a mistake when converting:

GH_String name = new GH_String();

string strName = "something";

bool convertStr = GH_Convert.ToGHString(strName, GH_Conversion.Both, ref name);

What is my (probably obvious) mistake?

Views: 409

Replies to This Discussion

Just make a new string...

GH_String name = new GH_String("something");

I mean, that didn't answer your specific question, and I can't see right away what would be wrong with the code, but GH_Convert is only useful if you don't know at the time of writing what sort of data you're going to have to deal with. If you already have a string, no need to rely on complicated conversion logic.

Many thanks Dave, that makes sense.

By the way, I realized that the problem I had was not related to the type conversion.

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