Grasshopper

algorithmic modeling for Rhino

Hi guys

I have a problem which I have resolved in what I believe to be a pretty cumbersome way, and am interested to see if anyone can offer a better solution.

So I have several lists of points, stored in two-dimensional arrays, eg. [[a,b,c]]
These have been exported from another program, and when I put the data in a panel, I believe python interprets the whole list of values as a single string.

In order to resolve this, I used several string splits and replaces to isolate the actual data I am after in a usable means, and then convert it to float values, so that I can turn them into 3d points.

I'm thinking surely there must be a better solution here? (Definition attached below as well).

Thanks in advance

Views: 1433

Attachments:

Replies to This Discussion

You can use eval(). You also need to change the x to List Access. It's currently set to Item Access.

Attachments:

Ahh! I did not know about eval()!

The reason I used item access was because I figured that way I was able to maintain the branches of the original data, is this still possible?

The easiest solution is to graft the input. You need to update the code though. I have tested but this will probably work.

xyzs = eval(x)

a = (Point3d(*xyz) for xyz in xyzs)

Wow! Thanks man! Much appreciated!

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