MeshContourPoints in python?

So i found this in VB, but i think maby MeshContourPoints does not exict in python.
Is there some other way of doing this?


You will need to go into RhinoCommon to do this:

First you will need to get the contour curves using


and use the mesh object, two points and a distance as arguments - like you do with the normal Rhino Contour command.

The result will be a list of curves, which you can convert to polylines with Curve.TryGetPolyline() As a RhinoCommon polyline object is just a list of points, you should be able to add the list to the document using scriptcontext…

I will try to work up an example in a few minutes…


Here is an example… I encapsulated the function in a definition, it can be simply added to any python script.

Let me know if there’s something you don’t understand., I will try to explain.


"""Gets mesh contour points similar to vb Rhinoscript function"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def GetMeshContourPoints(meshID,cp1,cp2,dist):
    """mesh is a GUID representing a Rhino mesh object
    p1, p2 are  point3d's indicating the direction normal to contours
    dist is the contour spacing """
    if mesh:
        if contours:
            for contour in contours:
                if rc: cPts.append(pl)
            return cPts

def TestMeshContourPoints():
    meshID=rs.GetObject("Select mesh to contour",32,True)
    if not meshID: return
    msg1="Contour plane base point"
    msg2="Direction perpendicular to contour planes"
    if not dirPts: return
    msg1="Distance between contours"
    if not cDist: return
    if ContourPtList:
        for ptList in ContourPtList:

Wow Mitch, thanks! It does look awsome! =) i will read through it and see if i understand what it does. converting the list of curves to polylines sounds like somthing i want to do :wink:


I have been testing and i found out that if i pick something realy large, like 100000 for
msg1=“Distance between contours”

i will only get one contour. i also want to be able to have it at an angle and not 90 degree from the ground plane.

i want to select three points, medial, lateral and mid point, have a contour running through them.

does this make any sense? i thought the VB version of MeshContourPoints could have a 3dvector as input to make this.

That seems normal, if the distance you enter is larger than the thickness of the part in the direction indicated, then you will only get 1 contour at the base point indicated.

That should also work. Keep in mind that the two points you choose do not need to be along a line orthogonal to the world coordinate system, they can be at any angle. This script should work pretty much identically to the normal Rhino Contour command, except that it outputs points and not contour curves.

As far as I can tell, the VB version takes two points as well.

In this case if you’re only looking for one contour, you can derive a plane from the three points, and use that as the input for CreateContourCurves() -

instead of

Rhino.Geometry.Mesh.CreateContourCurves(mesh, plane)


Mitch Thanks for all the assistance, it realy helps me alot. i did not know that i could use a plane, i have already a plane in place, i have been using points and vectors on that plane to do this! I will post my code when i is working :wink:

For anyone interested in using a plane to get the contour.
Just replace points with plane in Mitches exampel above. worked like a charm! =)