above script uses:
Rhino.DocObjects.RhinoObject.Description
which is not available in Rhino 5. Basically it returns the content of the _What
command which is then searched for the Record id. To get this in Rhino 5 you could use the clipboard to store the text like described here.
The problem is, you’ll have to do this before asking for a selection and limit your selection to objects which do not have a record id, so the myfilter
function could not be used. Instead you would have to select possible objects, run the _What
command , store the content in the clipboard, search for the record id of every object and limit the selection to allowed objects using GetObjectEx()
like below:
import rhinoscriptsyntax as rs
def CustomGetObjWithoutHistory():
rs.EnableRedraw(False)
all_objs = rs.AllObjects(True, False, False, False)
rc = rs.Command("_-What _Clipboard _Enter", False)
result = rs.ClipboardText() if rc else None
rs.ClipboardText("")
rs.UnselectAllObjects()
rs.EnableRedraw(True)
if result:
descriptions = result.split("\n\n")
searchlist = zip(all_objs, descriptions)
allowed_objs = [n[0] for n in searchlist if not "Record id:" in n[1]]
else:
allowed_objs = rs.NormalObjects(False, False)
id = rs.GetObjectEx("Select", 0, False, True, allowed_objs)
if not id: return
CustomGetObjWithoutHistory()
This works in V5, but has a 4 drawbacks, it is ugly, may be slow with many objects, clears the clipboard and it does not allow for a preselection.
c.