+ Reply to Thread
Results 1 to 3 of 3

Thread: Error in rs.MeshOutline()

  1. #1

    Error in rs.MeshOutline()

    Hi Steve,

    I came accros an Error, when using the rs.MeshOutline() function.

    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"
    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.


    In my opinion the root of the problem is the Line (588)
    python Code:
      polylines = mesh.GetOutlines(viewport)
    which in the case mentioned above returns "None"


    So here's my updated code:
    python Code:
      mesh.def MeshOutline(object_ids, view=None):
          """Creates polyline curve outlines of mesh objects
          Parameters:
            objects_ids = identifiers of meshes to outline
            view(opt) = view to use for outline direction
          Returns:
            list of polyline curve id on success
          """
          viewport = __viewhelper(view).MainViewport
          meshes = []
          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.
    Attached Files

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Hi Martin,
    I see this bug and am looking into making your suggested fix right now. I also got your pull request (thanks) from github.
    -Steve

  3. #3
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    This is now fixed.
    Thanks,
    -Steve

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts