Grasshopper

algorithmic modeling for Rhino

Hello,

I've been working on a C# component for quite some time now, and it was working just fine until I installed the new Grasshopper 0.9.0006. That's when this error showed up:

"Error: foreach statement cannot operate on variables of type ‘Rhino.Geometry.Curve’ because ‘Rhino.Geometry.Curve’ does not contain a public definition for ‘GetEnumerator’ "  

I'm going to assume something changed in rhinocommon. What changed? How do I deal with the part of the script that used a foreach loop on curves to make it work again?

Here's the script:

foreach(Block b in blocks) {
  b.zone = 0;
  foreach(Curve ci in boundaries_1) {
    if (ci.Contains(b.cen()) == PointContainment.Inside) {
      b.zone = 1;
    }
  }
}

I appreciate your help!

Tarek

Views: 1860

Replies to This Discussion

What type is boundaries_1? It sounds like a collection of some sort, but if it is a single Curve, then you cannot foreach it. Rhino.Geometry.Curve does not implement IEnumerable and to my knowledge never did. Something else must have gone wrong.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

boundaries_1 was a single Curve. It did work very well before, which is odd because it shouldn't now that I think about it. I fixed it, everything is fine now.


Thanks a lot David. 

Do you have a class definition for Block (in line: foreach(Block b in blocks))?  As far as I know, Grasshopper doesn't have a datatype for Block, so unless you've defined your own... this might be what is causing the issue.  Just a thought.

-Andy

Yes there a class definition for Block, but it turns out that the issue is in running a foreach loop on a single curve. For some reason it worked before, although it shouldn't have!

Thanks Andy.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service