Grasshopper Python - expected IEnumerable[Brep], got Brep

I’m trying to script ‘project points to a brep,’ but it’s not working, what am I doing wrong?
Thanks in advance for your response.

I cannot understand what IEnumerable is nor can I solve it with former posts of other similar problems with IEnumerable.

20181013 00 problem ienumerable (5.4 KB)

Hi ForestOwl
The program has no problem with me .like this

my gh file:
20181013 00 problem ienumerable (5.7 KB)

IEnumerable needs to be set to list, Here is a similar example.

1 Like

Do you now how to make it a IEnumerable within the script?
I looked at the link, but I do not know how to do that in Python.

20181013 01 problem ienumerable (15.3 KB)

IEnumerable is an interface that is implemented by pretty much every collection type class. Arrays, Lists, Dictionaries, ConcurrentBags, HashSets… you name it. If a class is designed to store a bunch of values it probably implements IEnumerable.

The reason for this is that IEnumerable allows you to easily loop over the values in a collection without knowing how many there are, and without the values having a specific defined order. This means using a foreach loop or whatever the Python equivalent is.

If you have an IEnumerable, all you can really do is foreach your way through that collection.


Either create a list from your brep ([brep]), or set the input to list access (right click on the input of your component to get the context menu).

1 Like

You need a list to add your brepface,like this.

My gh file:
20181013 01 problem ienumerable brep .gh (11.6 KB)

1 Like

Thank you for your responses.
Unfortunately, I get nuts from the real script I am working on (with custom functions).

Do you know what you know what the following means?

Runtime error (InvalidCastException): Error in IEnumeratorOfTWrapper.Current. Could not cast: Rhino.Geometry.Point3d in System.Guid

  line 45, in script

It is the same problem as in

I had a problem with the rc.Geometry.Vector3d. It is somehow recognized as a guide (see my post below).

I do not know what I am typing wrong. Please, see my previous post.

When I try to make a list, it does not work always.

I do not know what I am typing wrong. Please, see my previous post.

Can you upload your code? (1.6 KB)
Python-file MyMethods must be added to the folder C:\Users\NameUser\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts.
It is called

20181013 05 problem ienumerable (38.0 KB)

The rc.Geometry.Intersect.Intersection.ProjectPointsToBreps() method requires list[Point3d], so you need to convert the Guid to Point3d.

my gh file:
20181013 05 problem ienumerable brep(GUID).gh (31.8 KB)

1 Like

Thank you Naruto!
:grin: :