Python beginner - create temporary objects for user input?

I’m new-ish to scripting, and new to trying it out in rhino.
So wanted to start with something easy. I started with creating a point in the center of selected objects.
Great, so then I added creating a point at the center and bottom, also useful for my workflow often enough. But I also often want the center bottom back or front. And since imported objects are often facing X, Y, -X, or -Y, I don’t know which way that would be.

So I thought, it would be cool to just create a Bunch of points and let the user decide which one to go with.
I don’t know how to inform the user to select one of those points, and as soon as the user clicks one, remove the others. If I’m doing that with multiple objects, I would just have the first object selected show the points, then use that selection to define the other object’s points.

But I haven’t found examples yet that get user feedback in the middle of the script by selecting something new.

i think you’re looking for these
the methods under “userinterface”

Hi,

I made a quick example that might help you get started:

import rhinoscriptsyntax as rs


def pick_point( possible_point_ids ):
    
    # pick one of the input 
    picked = rs.GetObjectEx('pick the point you like', preselect=False, select=False, objects= possible_point_ids)
    if picked:
        picked_id = picked[0]
        return picked_id
    else:
        return None    
    


#create some arbitrary points for the example
points = [[n*10,n*10,n*10] for n in range(10)]
point_ids = rs.AddPoints(points)

#pick a point from point_ids
picked_id = pick_point( point_ids )
if picked_id:
    rs.SelectObject(picked_id)
    print 'picked point id: {}'.format(picked_id)
    print 'picked point : {}'.format(rs.PointCoordinates(picked_id))

rs.DeleteObjects(point_ids)

Does that make sense?
-Willem

Well, sort of. It seems rather complicated for this, but I think that’s just because You right things in a nice way that makes sure it doesn’t break if the user doesn’t something that isn’t expected. For me, just starting out, that seems superfluous at first and adds to the difficulty in understanding what is happening. So I have to break it down to something more like this, in order to understand what’s going on:

import rhinoscriptsyntax as rs


points = [[n*10,n*10,n*10] for n in range(10)]
point_ids = rs.AddPoints(points)
picked = rs.GetObjectEx('pick the point you like', preselect=False, select=False, objects= None)
rs.SelectObject(picked[0])
print 'picked point : {}'.format(rs.PointCoordinates(picked[0]))

point = rs.PointCoordinates(picked[0])
rs.AddPoint(point)

rs.DeleteObjects(point_ids)

Oh, and that drove me Nuts to even get to work. I was deleting the objects point_ids first, Then adding the point, but it gave me an error. I didn’t/don’t understand I guess a few things. I thought when I created the variable “picked” there, it was storing the value for that in that variable, but all that’s stored is a GUID, and not the coordinates?

I lost my work due to a crash also, but I Was getting the center point of a bounding box, but found out that the command I was using didn’t work on multiple objects. But I know that if I just run most everything as if I were doing it as a user, it’s really just basically making a macro, and that’s Really slow on large data sets.

Anyway, I’m frustrated again so feeling like it’s probably not worth my time to try and learn enough of this to become useful since it ends up taking a day of searching through commands enough to Half understand a fairly basic code you wrote. So leave it to the experts I guess.