Selected Object in Python

Hi all,

I’ve got this routine:

import rhinoscriptsyntax as rs

rs.GetObjects()
rs.InvertSelectedObjects()

Unfortunately, I don’t ghet the result I expected: whatever the objects I select with rs.GetObjects(), all objects are selected at the end of the script… Any idea why it does that?

Thank you!

JB

GetObjects just gets the identifier of the object so you can later on use that identification to tell python what to do with what. GetObjects returns a list, and that list needs a name. So do something like this:

myObjects=rs.GetObjects("select objects")

Now you have to tell Python that these objects are to be selected. One way is adding this line:

rs.SelectObjects(myObjects)

If you look at the help file you will see that GetObject() has options to it, so it possible to select the objects directly after you have picked them, or even have Python accept preselected objects and add filters so you can only select meshes, curves and/or polysurfaces etc, and/or only select objects from another list.

Good luck.

Hi,
By default picked objects are not selected. Try this:

rs.GetObjects(select=True)

Thank you very much!