+ Reply to Thread
Results 1 to 5 of 5

Thread: 'out' parameters with rhino common methods

  1. #1

    'out' parameters with rhino common methods

    Hello,

    I'm trying to use the rhino common Rhino.Geometry.Mesh.ClosestPoint (Point3d, Point3d, Vector3d, Double) method.

    The second Point3d and Vector3d arguments are output parameters. Would anyone be able to help me with the syntax for using this method (and other overloaded methods with output parameters) in RhinoPython?

    Paul

  2. #2
    in this case Ironpython returns a tuple, the second member in the tuple is your out parameter.

  3. #3

  4. #4

    MeshClosestPointNormal

    Thanks Goswin, I would have expected a tuple back, but it doesn't in this case, I think because the method is overloaded - it accepts input in both ClosestPoint (Point3d, Point3d, Vector3d, Double) and ClosestPoint(Point3d) forms.

    It seems IronPython can be persuaded to accept 'out' parameters as arguments defined with clr.Reference[Type]()

    The example below will return a mesh closest point, normal and face index.

    Paul

    24Sep12 - Fixed, see goswin's comment below

    python Code:
      import Rhino.Geometry as rg
      from clr import Reference
       
      def MeshClosestPointNormal(mesh, pnt, maxDist=0.0):
          """for a test point and a mesh, return the closest point, normal and face
             index on that mesh.
          input:
             mesh - guid of a mesh
             pnt - test Point3d
          returns:
             tuple containing (closest_point, normal, faceindex)
          """
          ret_pnt = rg.Point3d(0,0,0)
          ret_pnt = Reference[ret_pnt.GetType()]()
          ret_nrm = rg.Vector3d(0,0,0)
          ret_nrm = Reference[ret_nrm.GetType()]()
          face_idx = mesh.ClosestPoint(pnt, ret_pnt, ret_nrm, maxDist)
          return (ret_pnt.Value, ret_nrm.Value, face_idx)
    Last edited by PaulM; 09-24-2012 at 02:58 AM.

  5. #5
    Thanks Paul, I did not know this solution for overloaded methods.
    don't you need to do :
    return (ret_pnt.Value , ret_nrm.Value , face_idx)
    like described here:
    http://stackoverflow.com/questions/8...-specific-type
    Last edited by Goswin; 09-19-2012 at 02:59 PM.

+ 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