Activating additional "out" parameters RhinoCommon/Python

For example here:

The overloads include a couple of ‘out’ parameters and IIRC, I have to feed it some input types to get the out parameters - using clr.Strongbox. But I am not having much luck here, all I have is the test point and the mesh. Can someone remind me the correct syntax to use here? Thx.

Hi Mitch, below seems to do it:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import clr 

def DoSomething():
    mesh_id = rs.GetObject("Select mesh", 32, True, False)
    if not mesh_id: return
    test_point = rs.GetPoint("Point")
    if not test_point: return 
    m = rs.coercemesh(mesh_id, True)
    p = clr.StrongBox[Rhino.Geometry.Point3d]()
    n = clr.StrongBox[Rhino.Geometry.Vector3d]()
    face_index = Rhino.Geometry.Mesh.ClosestPoint(m, test_point, p, n, 0.0)
    if not face_index: return
    line = Rhino.Geometry.Line(p.Value, n.Value, 10)


1 Like

Hi Clement,

That’s pretty funny. I had basically the same as you, but I tried putting all sorts of things in the parentheses at the end of the strongbox lines - thinking that it needed some kind of value in there… The only thing I didn’t try was putting nothing… :upside_down_face:

Thanks !

Hi Mitch, i too find this confusing, the setup was easy to remember but accessing the results feels cumbersome (eg. p.Value)


FWIW out variables should never be initialized, not even in C#, which is why only the uninitialized boxes work.

1 Like