Skip to content

M_Rhino_Geometry_Collections_MeshFaceList_AddFace_2

Will Pearson edited this page Aug 12, 2016 · 2 revisions

MeshFaceList.AddFace Method (Int32, Int32, Int32, Int32)

Appends a new quadragular face to the end of the mesh face list.

Namespace: Rhino.Geometry.Collections
Assembly: RhinoCommon (in RhinoCommon.dll) Version: Rhino 6.0

Syntax

C#

public int AddFace(
	int vertex1,
	int vertex2,
	int vertex3,
	int vertex4
)

VB

Public Function AddFace ( 
	vertex1 As Integer,
	vertex2 As Integer,
	vertex3 As Integer,
	vertex4 As Integer
) As Integer

Parameters

 

vertex1
Type: System.Int32
Index of first face corner.
vertex2
Type: System.Int32
Index of second face corner.
vertex3
Type: System.Int32
Index of third face corner.
vertex4
Type: System.Int32
Index of fourth face corner.

Return Value

Type: Int32
The index of the newly added quad.

Examples

VB

Partial Class Examples
  Public Shared Function AddMesh(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
    Dim mesh As New Rhino.Geometry.Mesh()
    mesh.Vertices.Add(0.0, 0.0, 1.0) '0
    mesh.Vertices.Add(1.0, 0.0, 1.0) '1
    mesh.Vertices.Add(2.0, 0.0, 1.0) '2
    mesh.Vertices.Add(3.0, 0.0, 0.0) '3
    mesh.Vertices.Add(0.0, 1.0, 1.0) '4
    mesh.Vertices.Add(1.0, 1.0, 2.0) '5
    mesh.Vertices.Add(2.0, 1.0, 1.0) '6
    mesh.Vertices.Add(3.0, 1.0, 0.0) '7
    mesh.Vertices.Add(0.0, 2.0, 1.0) '8
    mesh.Vertices.Add(1.0, 2.0, 1.0) '9
    mesh.Vertices.Add(2.0, 2.0, 1.0) '10
    mesh.Vertices.Add(3.0, 2.0, 1.0) '11
    mesh.Faces.AddFace(0, 1, 5, 4)
    mesh.Faces.AddFace(1, 2, 6, 5)
    mesh.Faces.AddFace(2, 3, 7, 6)
    mesh.Faces.AddFace(4, 5, 9, 8)
    mesh.Faces.AddFace(5, 6, 10, 9)
    mesh.Faces.AddFace(6, 7, 11, 10)
    mesh.Normals.ComputeNormals()
    mesh.Compact()
    If doc.Objects.AddMesh(mesh) <> Guid.Empty Then
      doc.Views.Redraw()
      Return Rhino.Commands.Result.Success
    End If
    Return Rhino.Commands.Result.Failure
  End Function
End Class

C#

using System;

partial class Examples
{
  public static Rhino.Commands.Result AddMesh(Rhino.RhinoDoc doc)
  {
    Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();
    mesh.Vertices.Add(0.0, 0.0, 1.0); //0
    mesh.Vertices.Add(1.0, 0.0, 1.0); //1
    mesh.Vertices.Add(2.0, 0.0, 1.0); //2
    mesh.Vertices.Add(3.0, 0.0, 0.0); //3
    mesh.Vertices.Add(0.0, 1.0, 1.0); //4
    mesh.Vertices.Add(1.0, 1.0, 2.0); //5
    mesh.Vertices.Add(2.0, 1.0, 1.0); //6
    mesh.Vertices.Add(3.0, 1.0, 0.0); //7
    mesh.Vertices.Add(0.0, 2.0, 1.0); //8
    mesh.Vertices.Add(1.0, 2.0, 1.0); //9
    mesh.Vertices.Add(2.0, 2.0, 1.0); //10
    mesh.Vertices.Add(3.0, 2.0, 1.0); //11

    mesh.Faces.AddFace(0, 1, 5, 4);
    mesh.Faces.AddFace(1, 2, 6, 5);
    mesh.Faces.AddFace(2, 3, 7, 6);
    mesh.Faces.AddFace(4, 5, 9, 8);
    mesh.Faces.AddFace(5, 6, 10, 9);
    mesh.Faces.AddFace(6, 7, 11, 10);
    mesh.Normals.ComputeNormals();
    mesh.Compact();
    if (doc.Objects.AddMesh(mesh) != Guid.Empty)
    {
      doc.Views.Redraw();
      return Rhino.Commands.Result.Success;
    }
    return Rhino.Commands.Result.Failure;
  }
}

Python

import Rhino
import scriptcontext
import System.Guid

def AddMesh():
    mesh = Rhino.Geometry.Mesh()
    mesh.Vertices.Add(0.0, 0.0, 1.0) #0
    mesh.Vertices.Add(1.0, 0.0, 1.0) #1
    mesh.Vertices.Add(2.0, 0.0, 1.0) #2
    mesh.Vertices.Add(3.0, 0.0, 0.0) #3
    mesh.Vertices.Add(0.0, 1.0, 1.0) #4
    mesh.Vertices.Add(1.0, 1.0, 2.0) #5
    mesh.Vertices.Add(2.0, 1.0, 1.0) #6
    mesh.Vertices.Add(3.0, 1.0, 0.0) #7
    mesh.Vertices.Add(0.0, 2.0, 1.0) #8
    mesh.Vertices.Add(1.0, 2.0, 1.0) #9
    mesh.Vertices.Add(2.0, 2.0, 1.0) #10
    mesh.Vertices.Add(3.0, 2.0, 1.0) #11

    mesh.Faces.AddFace(0, 1, 5, 4)
    mesh.Faces.AddFace(1, 2, 6, 5)
    mesh.Faces.AddFace(2, 3, 7, 6)
    mesh.Faces.AddFace(4, 5, 9, 8)
    mesh.Faces.AddFace(5, 6, 10, 9)
    mesh.Faces.AddFace(6, 7, 11, 10)
    mesh.Normals.ComputeNormals()
    mesh.Compact()
    if scriptcontext.doc.Objects.AddMesh(mesh)!=System.Guid.Empty:
        scriptcontext.doc.Views.Redraw()
        return Rhino.Commands.Result.Success
    return Rhino.Commands.Result.Failure


if __name__=="__main__":
    AddMesh()

Version Information

Supported in: 6.0.16224.21491, 5D58w

See Also

Reference

MeshFaceList Class
AddFace Overload
Rhino.Geometry.Collections Namespace

Clone this wiki locally