How to get Cplane coordinates from GetPoint?

When you go to the right view and run this python code, how do you get the Cplane coordinates instead of the World coordinates as it does now?

import Rhino
import rhinoscriptsyntax as rs

def PointCoordinates():
    
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Select point")
    
    while True:
        
        gp.ClearCommandOptions()
        
        get_rc = gp.Get()
        
        if gp.CommandResult()!=Rhino.Commands.Result.Success:
            return gp.CommandResult()
        
        if get_rc==Rhino.Input.GetResult.Point:
            point = gp.Point()
            print point
        if get_rc == Rhino.Input.GetResult.Cancel:
            break
    return Rhino.Commands.Result.Success

if __name__ == "__main__":
    PointCoordinates()

hi @siemen

for me the gp.Point() is in world coordinates, for example here i am picking cPlane(x=10, y=20) but point prints (0, 10, 20) which is the expected result in world coordinates.
Are you seeing something different?

Wait, you’re right. I might be mixing up stuff here. I need the Cplane coordinates instead of the Worldcoordinates. :smiley:

I adjusted the title and post.

have a look at https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Plane_RemapToPlaneSpace.htm

import Rhino
import scriptcontext as sc


def PointCoordinates():
    
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Select point")
    cPlane = sc.doc.Views.ActiveView.ActiveViewport.ConstructionPlane()
    
    while True:
        
        gp.ClearCommandOptions()
        
        get_rc = gp.Get()
        
        if gp.CommandResult()!=Rhino.Commands.Result.Success:
            return gp.CommandResult()
        
        if get_rc==Rhino.Input.GetResult.Point:
            point = gp.Point()
            print "Picked point in world coordinates: " + str(point)
            bSuccess, pointPulled = cPlane.RemapToPlaneSpace(point)
            print "Picked point in plane coordinates: " + str(pointPulled)
        if get_rc == Rhino.Input.GetResult.Cancel:
            break
    return Rhino.Commands.Result.Success

if __name__ == "__main__":
    PointCoordinates()
1 Like

Thanks!