Hi Steve,
I came accros an Error, when using the rs.MeshOutline() function.
The Error occurs, when trying to get the Mesh Outline of a Mesh, who's members are all completely oriented in the Viewports Normal direction (in Parallel View). I attached a file.Code:Message: iteration over non-sequence of type NoneType Traceback: line 589, in MeshOutline, "C:\Users\Martin\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\mesh.py"
In my opinion the root of the problem is the Line (588)
which in the case mentioned above returns "None"python Code:
polylines = mesh.GetOutlines(viewport)
So here's my updated code:
python Code:
mesh.def MeshOutline(object_ids, view=None):"""Creates polyline curve outlines of mesh objectsParameters:objects_ids = identifiers of meshes to outlineview(opt) = view to use for outline directionReturns:list of polyline curve id on success"""viewport = __viewhelper(view).MainViewportmeshes = []mesh = rhutil.coercemesh(object_ids, False)if mesh: meshes.append(mesh)else: meshes = [rhutil.coercemesh(id,True) for id in object_ids]rc = []for mesh in meshes:polylines = mesh.GetOutlines(viewport)if polylines:for polyline in polylines:id = scriptcontext.doc.Objects.AddPolyline(polyline)rc.append(id)scriptcontext.doc.Views.Redraw()return rc
I added "if polylines"
It the returns [] instead of an error.
- Martin
P.S.: I attached a file which throws the exception if the Viewport is the Gloabal XY Plane and Parallel.


Reply With Quote