Handle _Paste command with GetPoint class (the GetBaseClass -> GetString,...)

Hello,

I spend a bunch of time trying to collect data send by _Paste command during the execution of the GetPoint class into a loop. The loop is working by entering values manually, but not with the _Paste command.
My goal is to immit the _Points command.
See the capture bellow.
image

I’ve tried almost every GetBaseClass methods unsuccessfully. (AcceptNothing, AcceptString, EnableTransparentCommands, AcceptEnterWhenDone, …)

I’ve tried with :
Rhino.Input.RhinoGet.GetPoint object
Rhino.Input.Custom.GetPoint object
rhinoscriptsyntax.getPoints → which use the RhinoCommon API as well

I’m all available to discuss this issue, thank you so much for your help.

The code trials down here:

#with RhinoGet
string = “enter points”
import rhinoscriptsyntax as rs
import Rhino.Geometry.Point3d as Point3d
import clr
import Rhino
outPoint = clr.StrongBoxPoint3d
points =
bool = Rhino.Input.RhinoGet.GetPoint(string, True, outPoint)
while bool == Rhino.Commands.Result.Success:
point = outPoint.ToString()
print(point)
points.append(point)
bool = Rhino.Input.RhinoGet.GetPoint(string, True, outPoint)
rs.AddPoints(points)

#with Input.Custom
string = “enter points”
gs = Rhino.Input.Custom.GetPoint()
gs.SetCommandPrompt(string)
# gs.SetDefaultString(string)
gs.AcceptEnterWhenDone(True)
gs.AcceptNothing(True)
gs.AcceptString(True)
gs.EnableTransparentCommands(True)
gs.Get()
# gs.GetLiteralString()
points = [gs.StringResult().Trim()]
while gs.CommandResult() == Rhino.Commands.Result.Success:
gs.Get()
prevString = gs.StringResult().Trim()
values = prevString.split(",")
if len(values) == 3:
points.append(map(float, values))
rs.AddPoints(points)

Up !

This seems to work pretty good:

import Rhino
import scriptcontext as sc

def test_point_paster():
    points = []
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Location of point")
    while (True):
        gp.Get()
        if (gp.CommandResult() != Rhino.Commands.Result.Success):
            break
        points.append(gp.Point())
        gp.SetCommandPrompt("Location of point. Press Enter when done")
    
    for pt in points:
        print(pt)

if __name__ == "__main__":
    test_point_paster()

– Dale

Thank you very much Dale for the answer. I just tried it in Rhino 6 without success, do you use Rhino 7 maybe ?

I tried it on Rhino 7 without sucess. It seem’s that the 'Paste command behave in a particular manner.

If anyone from Mc Neel can tell us more about it.

Thank you,
Gaspard

An alternative to solve this issue is to use the Grasshopper Player. You can copy a part of your code in a GH Python block and use the new blocks from Rhino V7 :

  • Get Point
  • Get String

You can _Paste whater you want during the prompt of those new blocks.

Refer to this Steve Baer’s tutorial for more information:

Or visit this interesting thread:

As the paste command is available from the Grasshopper Player, it would be great to have the code allowing it ?

I didn’t find anything related to that in the API.