+ Reply to Thread
Results 1 to 5 of 5

Thread: Get Mesh Faces, Get Mesh Vertices

  1. #1

    Get Mesh Faces, Get Mesh Vertices

    Hello All,

    I'm planning to write two scripts for editing mesh objects : extrude a mesh face, bridge between mesh faces

    and I was wondering if there is any plan for implement get mesh faces or get mesh vertices?

    or if I can use any alternative methods ?

    Many Thanks
    Riccardo

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    Hi Riccardo,
    Are you referring to specific RhinoScript functions that have not been ported to python? I can't find any with those types of names.

    If the RhinoScript functions don't exist, I can probably help you mix a little RhinoCommon into your python script to get at what you need.
    Thanks,
    -Steve

  3. #3
    Hi Steve,

    Yes I was referring to the RhinoScript functions!
    anyway before reading your post I did not realize that RhinoCommon can be used with python
    So I spent around 8 hours looking in to it ( I do not have a background in programming) and finally come out with this :

    Python Code:
      import Rhino
      import scriptcontext
      import System.Guid
      import rhinoscriptsyntax as rs
       
       
      def PickMeshFace():
         
         
          # get the mesh face from rhino viewport
          PickMeshFace = Rhino.Input.Custom.GetObject()
          PickMeshFace.GeometryFilter = Rhino.DocObjects.ObjectType.MeshFace
          PickMeshFace.SetCommandPrompt("Select Mesh Face")
          PickMeshFace.Get()
         
          if PickMeshFace.CommandResult()!=Rhino.Commands.Result.Success:
              return gs.CommandResult()
         
          # Rhino.Input.Custom.GetObject .Object() to Rhino.DocObjects.ObjRef
          objref = PickMeshFace.Object(0)
         
          return objref
       
      def GetFaceIndex(objref):
         
          # Rhino.DocObjects.ObjRef .GeometryComponentIndex to Rhino.Geometry.ComponentIndex
          MeshFaceIndex = objref.GeometryComponentIndex
         
          return MeshFaceIndex.Index
       
       
      Face_1_Ref = PickMeshFace()
       
      print "This is the mesh ID"
      print Face_1_Ref.ObjectId
      print "This is the Rhino.Geometry.Mesh "
      print Face_1_Ref.Mesh()
      print "This is the Face index"
      print GetFaceIndex(Face_1_Ref)

    with this i can get index of the selected mesh face and the mesh id
    if you see a better solution in order to get the (face index and meshID) or you can foresee any problem with this I would appreciate if you post a correction... thanks

    Riccardo
    Attached Files
    Last edited by Riccardo; 07-29-2012 at 06:26 PM.

  4. #4
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    Hi Riccardo,
    My mistake, I was looking in the wrong spot in the RhinoScript functions and just missed these. I just added them to python so they should be available in the next V5 Beta. You can also get them from gituhub at
    https://github.com/mcneel/rhinopytho...erinterface.py
    but it looks like you've already solved your problem by just directly accessing RhinoCommon

    Thanks,
    -Steve

  5. #5
    Thanks for sending the Github link !

    Best
    R

+ Reply to Thread

Tags for this 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