__str__ and ToString for DocObjects

Unless there is a good reason not to, please change the return values of DocObjects’ __str__ and ToString to include the class type.

import rhinoscriptsyntax as rs

def main():
    
    guid = rs.GetObject(preselect=True)
    if guid is None: return
    
    rdObj = rs.coercerhinoobject(guid)
    
    sPrint = 'rdObj'; print sPrint + '\n', eval(sPrint)
    sPrint = 'rdObj.ToString()'; print '\n' + sPrint + '\n', eval(sPrint)
    sPrint = 'rdObj.__repr__()'; print '\n' + sPrint + '\n', eval(sPrint)

if __name__ == '__main__': main()

V5:

rdObj
<Rhino.DocObjects.PointObject object at 0x0000000000000031 [Rhino.DocObjects.PointObject]>

rdObj.ToString()
Rhino.DocObjects.PointObject

rdObj.__repr__()
<Rhino.DocObjects.PointObject object at 0x0000000000000031 [Rhino.DocObjects.PointObject]>

V6:

rdObj
ModelGeometry: (unnamed) (0)

rdObj.ToString()
ModelGeometry: (unnamed) (0)

rdObj.__repr__()
<Rhino.DocObjects.PointObject object at 0x0000000000000032 [ModelGeometry: (unnamed) (0)]>

Thank you,
Steve

Reported: https://mcneel.myjetbrains.com/youtrack/issue/RH-41704

This will be fixed in next week’s WIP. However, a small warning: you should not rely on the name to be present for behavior, but only to help your own debuigging/testing.
You should use GetType().FullName and similar to get the type name. Does it help?

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Yes, this is for debugging.

Thanks