Grasshopper

algorithmic modeling for Rhino

Hello,

First of all: Thanks to the Grasshopper and GHPython community for your quick and helpful answers! This has been a great help in the last weeks.

Here is my current problem:

I have created a CSV file in OpenOffice describing stair case types and have imported it via GHPython.

I decided to store it as a dictionary so that each key (e.g. "a" indicating "Stair case type a") has an associated list of values (e.g. "1.2" as a width or "B" as a remark describing something else).

Question 1: Is that clever? This is the first time I have ever used dictionaries.

Question 2:

When I use type() to find out if I have successfully converted one of the items in a value (which is a list) from a string to a float I get an error. Here is an excerpt of the script:

This usually works fine in GHPython, so I'm guessing it has something to do with the CSV? Any help much appreciated.

I have attached the definition and CSV file.

Cheers,

Max

Views: 544

Attachments:

Replies to This Discussion

Hi Max. It works fine on my machine. You sure you don't just have a phantom variable (you might have assigned the name type to a variable, overriding the type() function)? A good check is to simple close/open the file. /Anders

Ha! Spot on, thanks Anders :)

So would you use dictionaries for this task or is there a better way?

Yeah, I think that sounds like a pretty good strategy. You could also make a class, but that's probably overkill unless you also want to have some functions which operate on the data. We can discuss it on Friday ;)

Sounds good, cheers!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service