MeshVertexList.Point3dAt (not working?)

Hello

When I use:
Rhino.Geometry.Collections.MeshVertexList.Point3dAt

I get error: ‘type’ object has no attribute ‘Point3dAt’

Then I used:
Rhino.Geometry.Collections.MeshVertexList.ToPoint3dArray
and I get the coordinates of the vertex from it.

Not very efficient though when this has to be used on a big set of vertices.

When I type the above in the Python editor ToPoint3dArray does autocomplete, while Point3dAt does not autocomplete.

Any idea why this happens?

Thanks

Perhaps because Rhino.Geometry.Collections.MeshVertexList has no method or property called “Point3dAt”? What leads you to believe it does?

It does…
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Collections_MeshVertexList_Point3dAt.htm

The method needs an index as an argument…

image

Thanks, Mitch. I was kind of shooting from the hip; I’m not that familiar with Python and assumed it’s error system was a little more sophisticated than it appears to be, Seems more in the VBS category.

Dunno, this is RhinoCommon and doesn’t have all that much to do with Python, in any case, if you ran some code in C# and didn’t supply an argument to a method that required one, what kind of error message would you get?

Hi

Point3dAt seems to work here on Rhino 6.
Maybe you tried it on Rhino 5 ? :slight_smile:

Hello again and thanks for the responses.

I am new to Python and Rhino so perhaps I am not doing something correctly.

Here is what I try to run (I just pick a mesh primitive box I have created):

import rhinoscriptsyntax as rs
import Rhino

def test():
    MeshID = rs.GetObject("Pick a Mesh")
    Mesh = rs.coercemesh(MeshID)
    
    VertexCoordinates = Rhino.Geometry.Collections.MeshVertexList.Point3dAt(1)
    
    print VertexCoordinates

test()

And this is what I get:
‘type’ object has no attribute ‘Point3dAt’

Am I missing something in the code for Point3dAt to work or any idea what else could be causing this?

Thanks

VertexCoordinates = Rhino.Geometry.Collections.MeshVertexList.Point3dAt(1)

should read

VertexCoordinates = Mesh.Vertices.Point3dAt(1)

Your code tries to use Point3dAt method on the type MeshVertexList. Hence the error message contains the word type.

My suggested line uses the Vertices property on the mesh instance. The property gives access to the mesh vertices through in instance of type MeshVertexList. Since it is an actual object of type MeshVertexList the call to method Point3dAt works.

Hello Nathan,

I have tried this too and it give same error. Just tried again and it does not work.

@qtov, did you try this in v5? If you did, then there is no Point3dAt method on MeshVertexList. It got introduced in v6.

This does work and returns the coordinates of the vertex:

This is all executed on Rhino 6

But I have to go get the whole array just for 1 vertex:

import rhinoscriptsyntax as rs
import Rhino


def test():
    MeshID = rs.GetObject("Pick a Mesh")
    Mesh = rs.coercemesh(MeshID)
    
    VerticesList = Mesh.Vertices
    
    VerticesListCoordinates = Rhino.Geometry.Collections.MeshVertexList.ToPoint3dArray(VerticesList)
    
    print VerticesListCoordinates[1]

test()
import rhinoscriptsyntax as rs
import Rhino


def test():
    MeshID = rs.GetObject("Pick a Mesh")
    Mesh = rs.coercemesh(MeshID)
    
    vp = Mesh.Vertices.Point3dAt(1) # on v6
    print(vp)

test()

image

Thanks for your response.

Perhaps I have to reinstall Rhino, the code you give does not work for me.
I have spent plenty of time trying to get it to work. As I am new to all this I was thinking I don’t understand how to apply this.

Have you tried copy/pasting exactly my script in an empty python script and run that?

On what Rhino v6 version are you? Run the Rhino command _SystemInfo and paste the entire first line of the result. I am on Rhino 6.6

This may still be the problem though :slight_smile: In your response here:

you for instance use Rhino.Geometry.Collections.MeshVertexList as such. The ToPoint3dArray method is supposed to be used on an instance: VerticesListCoordinates = Mesh.Vertices.ToPoint3dArray().

You did something similar in your very first snippet, where you typed VertexCoordinates = Rhino.Geometry.Collections.MeshVertexList.Point3dAt(1). That is wrong, you are using the type Rhino.Geometry.Collections.MeshVertexList. As mentioned you should instead call the Point3dAt method on an instance of the type. In your case such an instance is available through Mesh.Vertices in your code.

@jesterking I tried the script exactly as you wrote it and it does not work for me

After your and Nathan’s comments I understand I should not use the whole path to the method and will write it as you both suggested from now on. Although the version I posted for the whole array does work. Trying Nathan’s recommendation on how to point to the actual Mesh vertices information and trying your script, copy pasted exactly with no changes on my part still gives the same error. I will report back when I reinstall and perhaps try on another machine.

Could this be related to IronPython somehow? I remember a while back I had installed another program which installed another verison of IronPython and then my Python scripts (in Rhino) stopped working. So I went and uninstalled IronPython and I don’t really remember if I installed another version… but then scripts got fixed and were running good in Rhino.

@qtov could you still reply with what exact Rhino 6 version you are on? (_SystemInfo)

Reinstalling seems to have fixed the problem :slight_smile:

Thanks all for helping!

@jesterking I am on the latest release version

Good to hear (: