Create Surface from Points in Rhino Python, Message: expected IEnumerable[Point3d], got list

I am trying to create a surface in rhino from points (x,y,z) usually from 3 or 4 for a surface from a citygml file. After a lot of research I found AddPlanarSrf() method does this job from curves, but not all the surfaces of buildings in citygml are planar. some of the curves created from these points are non planar, So I got some null surfaces. I researched for another method to do the same task. But this time, I used AddSrfControlPtGrid() but it gives me errors like

Can someone please guide me with this? how to create surfaces from points in general using rhino python

There’s a lot going on there that I can’t really comment on (mac, rhinoscriptsyntax etc.). But, occasionally the underlying RhinoCommon method (i.e. this one) requires an explicit list type (i.e. a regular Python list won’t do). In this case of type Point3d. When this happens I usually just wrap my Python list in a Point3dList. Something like this:

import Rhino as rc

ptsPyList = [rc.Geometry.Point3d(0,0,0),rc.Geometry.Point3d(1,2,3)]
ptsList3d = rc.Collections.Point3dList(pts)

Also, welcome to the forum. We encourage people to provide an example file that demonstrates their issue. This helps tremendously when trouble-shooting etc. :slight_smile:

Edit: A more general solution that’ll work with other types, is something like this:

import Rhino as rc
from System.Collections.Generic import List

ptsPyList = [rc.Geometry.Point3d(0,0,0),rc.Geometry.Point3d(1,2,3)]
ptsList3d = List[rc.Geometry.Point3d](ptsPyList)

Thank you so much @AndersDeleuran for your quick response. can you also shed me some knowledge about how do I choose the u and v values? I have no idea what u and v are, and the degree would be (3,3) for 3d points? please correct me if I am wrong . Thanks

The u and v parameters is how many points you have along each direction in your grid. The degree determines the degree of the output surface in the two directions (edit: go through this article). You can maybe have a look at the old Grasshopper definition I posted over here. It has a GHPython component towards the end that makes surfaces from grids on a quad mesh.

Edit: Here’s a minimal working example in both rhinoscriptsyntax and RhinoCommon: (4.2 KB)

1 Like

Thanks @AndersDeleuran for this suggestion, but it quite exactly doesn’t work. I want a surface something like this.

but it draws this weird shape of two triangles,
(upload://y8D12Bq03uFBMhgU2AGAQgUE6UD.png) do you have any idea how to solve this? also sometimes I have points with prime numbers like 5,7,11,13 for each surface in that case, it can return a null surface because the u and v will be either (1,prime number) or (prime number,1) . So I would prefer a method to create surface without u and v and knots, I could not find any for now. Thank you for your suggestions. Also, I am trying to implement all of it in python to read a citygml file and display it on rhino without any use of components from Grasshopper, since I am trying to develop a plugin. I hope you understand my use case.

As I said yesterday:

It’s really impossible for us to help you otherwise. It could be any number of things. So please upload a Rhino file and Python script that demonstrates your issue.

And please do not double post:

@AndersDeleuran sorry for the duplicate post, (781 Bytes)

this is the script I am writing and using rhino-python plugin on atom editor to see the updates on the rhino. Thanks

No worries. If you need to make surfaces from four corners, you can implement this method:

Which implements this method under the hood:

@AndersDeleuran yes, I figured that out and in some cases I need to create surface from more four points and sometimes with prime number of points too