rs.ObjectName Throwing 'str is not callable' Error

Here is the relevant code.

    fingerRail = rs.AddCircle(rs.WorldZXPlane(), rad)
    #name = 'Size {:.3f} + {:.3f}'.format(opt.Size, offset)
    name = 'fred'
    rs.ObjectName(fingerRail, name)

fingerRail is a populated GUID and name is a string when it calls:

But I get a ‘str is not callable’ error and the name is not changed.

image

Hmm - this seems to work in both Rhino 6 and 7:

import rhinoscriptsyntax as rs

def test_object_name():
    curve_id = rs.AddCircle(rs.WorldXYPlane(), 5.0)
    rs.ObjectName(curve_id, 'Fred')
    print(rs.ObjectName(curve_id))

if __name__ == "__main__":
    test_object_name()

Is there anything else I can do to help debug? I’m just sticking it in as an attribute for now:

    fingerRail = rs.AddCircle(rs.WorldZXPlane(), rad)
    label = '{:.3f} + {:.3f}'.format(opt.Size, offset)
    #rs.ObjectName(fingerRail, label)
    rs.SetUserText(fingerRail, 'Size', label)

Restarted Rhino and it’s working:

    fingerRail = rs.AddCircle(rs.WorldZXPlane(), rad)
    label = '{:.3f} + {:.3f}'.format(opt.Size, offset)
    rs.ObjectName(fingerRail, 'Size: ' + label)
    rs.SetUserText(fingerRail, 'Size', label)

I suspect you typed rs.ObjectName = 'fred' or similar at some point, overwriting the function with the string. :slight_smile:

No, just restarted and uncommented and it worked.

Here’s the full script (it’s made for non-programmers to customize defaults):

RhinoScripts/FingerRail.py at main · EricM81/RhinoScripts (github.com)

I also found the CmdOption index to be weird and resorted to matching a selected option by string.