"str is not callable" with CurrentLayer method

In a python script, I am trying to change the current layer by using rs.CurrentLayer(‘mylayer’) .
During the first run of the script this works fine, however, on subsequent runs I get a message “str is not callable”. This happens also when I revert the Rhino file to the point where I ran the script the first time, and even if I use the script on a new drawing! (after closing the old drawing). The only way I can get it to work again is to quit Rhino and restart it.
Anybody any idea?

Edit: I found a solution. The root problem was in not using the right method to get back to the original current layer.

Could you post a sample that demonstrates this problem? It will be a lot easier to help track down what is going on.

This is the code I used:

Make ‘Duplications’ the current layer


Return to original current layer


I know now that the second expression is rubbish, so I used the following instead.


But somehow the rubbish expression caused the “str is not callable” message on the second pass, with a reference to the first expression, so that was were I searched for the fault.

This is the problem. You are reassigning the function rs.CurrentLayer to be a string and then trying to use rs.CurrentLayer as a function when python now knows that it is a string.

OK Steve, I understand it now. Thank you.

Hi Steve, I was thinking of bumping the topic because I just got the same error message, using the example of Python help:
import rhinoscriptsyntax as rs

I also tried with an even more simple script like this one:
import rhinoscriptsyntax as rs

I still get the error message “str is not callable”. Can you help me? Thanks

Ok I don’t know what was wrong but I just close Rhino and open it again and now it is working