Meshoutline via Python (Rhino 5)

I’ve used Rhino for years however new to Python Scripting in Rhino 5. I’d like to use MeshOutline for batch jobs. The command works perfect with my hands on. However, it refused to corperate viaPython script. (either polysurface or mesh). I extracted partial code and error message I got below:

rs.CurrentView('Top')
objs = rs.AllObjects(select=True)
for obj in objs: 
    print "Object identifier: ", objs

rs.MeshOutline(objs)

I appreciate any input!

Hi @Kenny2,

How about this?

import rhinoscriptsyntax as rs

rs.CurrentView('Top')
meshes = rs.ObjectsByType(32)
if meshes:
    curves = rs.MeshOutline(meshes)
    if curves:
        rs.SelectObjects(curves)

– Dale

HI Dale,

Thank you for the reply. the proposed code will not meet the requirement for the purpose.
Despite it needs to be meshed first, the contour lines are excessive(Right). I simply like to get the edges as shown on the left.

Is there any other way to achive? thanks in advance.

Hi @Kenny2, to get the same behaviour as the command, you might script the command:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    
    msg = "Select surfaces, polysurfaces and meshes to outline"
    obj_ids = rs.GetObjects(msg, 8+16+32, True, True, True)
    if not obj_ids: return
    
    rc = rs.Command("_MeshOutline", False)
    if not rc: return
    
    outline_ids = rs.LastCreatedObjects(True)
    print "{} outlines created".format(outline_ids.Count)
    
DoSomething()

_
c.