How to use Brep.CreatePatch method?

more precisely this part:

System.Collections.Generic.IEnumerable<GeometryBase>

Thanks in advance.

Means a list of GeometryBase. The documentation of CreatePatch tells you what objects it takes:

So create a list with your geometry, then feed it into CreateBrep. If you search the forum for IEnumerable and python you’ll find many discussions on the beast called IEnumerable

Hi @nathanletwory,

It is no so much about creating a list of my curves but rather how to call this bloody overload method.

I tried this before I ran out of ideas:

brep = Rhino.Geometry.Brep.CreatePatch.Overloads[System.Collections.Generic.IEnumerable[Rhino.Geometry.GeometryBase],System.Int32,System.Int32,System.Double](curves_list,4,4,tol)
# set up your parameters
yourlist = [create your list here]
yourstartingsurface = None # or the surface you retrieved somewhere from
uspans = 4
vspans = 4
trim = True
tangency = True
# etc... note, fixedges is a list with four booleans, as per documentation

# make the call
thebrep = Rhino.Geometry.Brep.CreatePatch(yourlist, yourstartingsurface, uspans, vspans, trim, tangency, pointspacing, flexibility, surfacepull, fixedges, tolerance
1 Like

So I have to use Overloads[] only when I have same number of arguments?

Update:
We’re coming back to my original question.

How to convert from list to IEnumerable? zip?

Update2:
NVM, I got it:

lst = [1,2,3,4,5,6,7]
list_enumerable = enumerate(lst)

Why is this done?
Why is enumerable used instead of a simple list?

:thinking:
Nope that’s not it:

Done:
This is my convertor from python list to IEnumerable:
:angry: That was tough to figure out, please add this to the examples McNeel

def enumegator(py_list=None):
    if py_list == None:return
    net_enumerable = System.Collections.Generic.List[Rhino.Geometry.Curve]()
    for i in py_list:
        net_enumerable.Add(i)
    return net_enumerable
2 Likes

IEnumerable as argument to a function is used to allow more flexible calls of said function.

If the argument would be an array you could only call it by supplying an array.

Since Array, List and some other collections all implement the enumerator interface they can be all used as argument on a function call which requires IEnumerable.

Otherwise you would need to write a function overload for every type of collection.

1 Like

Ah, I see, this is that bad-typing disadvantage of .net (csharp) :wink:

Hmm, actually if you think about it, this is a way csharp developers try to copy the beautiful duck-typing of python. Since this IEnumerable can be numerous list-types.:stuck_out_tongue_winking_eye:

@ivelin.peychev

if an rs… method exists, I always suggest you look at that code first to see how they structured it. In the case of AddPatch (which uses Brep.CreatePatch) you can see how they got all the different geometry types in there…

1 Like

Good point. I usually do that, in this case I started my development from a creating a planar surface, and got to patch with trial and error. At that point I was more focused on RhinoCommon and totally forgot to check rhinoscriptsyntax

@Helvetosaur, another confusion is the decision where to look for the solution.
The rhinoscriptsyntax is one thing, but they are not added to the documentation as examples.

Also there are some examples in github, some examples in the documentation of RhinoCommon, and also some articles in the wiki.mcneel.*
Also a lot of examples in discourse.mcneel.com

I believe the solution should be some search engine to index all examples from these sourses.

Yep, would be a good idea.

I struggled with the same thing for an hour now, IEnumerable is tough to figure out… and to understand. Thanks for posting this here!