Creating MeshFaceList type

Hello,

I’m trying to use Rhino.Geometry.Collections.MeshFaceList.AdjactedFaces method which asks for self: MeshFaceList, faceIndex: int as input. The script editor outputs that AdjactedFaces method takes exactly 2 arguments, but I can’t get over with MeshFaceList type.

Mesh created by Rhino.Geometry.Mesh.Vertices.Add() and Rhino.Geometry.Mesh.Faces.AddFace() used in AdjactedFaces outputs:

Runtime error (ArgumentTypeException): expected MeshFaceList, got Mesh

Can you explain the construction of MeshFaceList to a beginner and give an example of python script which uses MeshFaceList please?

Thanks
Michał

Do you have a small sample of the script that is not working? Maybe I can use that to help.

Hi Steve,

So this is what happens. V and F are list access; A, B and C are item access. All with no type hints. Same error with F instead of mesh as an argument for AdjactedFaces.

import Rhino as rh
import rhinoscriptsyntax as rs

mesh = rh.Geometry.Mesh()

for i in range(0, len(V)):
    mesh.Vertices.Add(V[i])

for i in range(0, len(F)):
    mesh.Faces.AddFace(A, B, C)

mesh.Normals.ComputeNormals()
mesh.Compact()

rh.Geometry.Collections.MeshFaceList.AdjacentFaces(F, 6)

AdjactedFaces.3dm (192.9 KB)
AdjactedFaces.gh (12.5 KB)

Create a python component with a single input named mesh and give it a typehint of Mesh. Wire the Mesh component output directly to this new python component. Inside the python component, write

print mesh.Faces.AdjacentFaces(6)

Let me know if that makes sense. Thanks,
-Steve

1 Like

It worked. The component outputs an array of adjaced faces’ indicies.

Thanks,
Michał

A post was split to a new topic: Extract Mesh Faces with Naked Edges