Issue with rs.getpointonmesh()

Hi, I am having issues with rs.GetPointOnMesh() where when I click outside of the mesh it returns (0,0,0) instead of “Null”.

Is this intended?
If it is intended then how should I detect if a mesh isn’t clicked on or if the mesh had a vertice at (0,0,0) that was clicked at?

This goes for both V5 and V6

Cheers.

Hi Jørgen,

i think this could be improved in RhinoScript syntax so it does not return a point when no pick was done on the mesh. Below is a possible workaround:

import Rhino
import rhinoscriptsyntax as rs

def DoSomething():
    
    id = rs.GetObject("Pick a mesh", rs.filter.mesh, True, False)
    if not id: return
    mesh = rs.coercemesh(id, True)
    
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Point on mesh")
    gp.Constrain(mesh, False)
    gp.Get()
    
    if gp.CommandResult() != Rhino.Commands.Result.Success: 
        return 
    
    print gp.Point()
    
DoSomething()

_
c.

1 Like

Thanks, I’ll test that out!