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.
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.
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
rs.AddLayer(“MyLayer”)
rs.CurrentLayer(“MyLayer”)
I also tried with an even more simple script like this one:
import rhinoscriptsyntax as rs
rs.CurrentLayer(“MyLayer”)
I still get the error message “str is not callable”. Can you help me? Thanks