A bug was discovered in SR12 (also affects Rhino for Mac 5.0.2 and earlier) yesterday that explains why some of you have started getting a “Message: ‘module’ object has no attribute ‘_’” error.
A script that looks like this:
import rhinoscript.userinterface
import rhinoscriptsyntax as rs
rs.GetLayer()
generates the error:
"Message: 'module' object has no attribute 'GetLayer'"
What appears to be happening is that the 1st import loads the userinterface module so when the 2nd import statement runs the module is not reloaded and therefore the rs alias is not associated with functions in the userinterface module. The script works after deleting the 1st import and reseting the script engine so it looks like the explanation is correct.
But the above script works in SR11 which mean that the explanation is in fact incorrect. After some digging a bug was discovered in SR12 that causes this problem. The bug only manifests itself in scripts that have the line “import rhinoscript.userinterface” followed by the line “import rhinoscriptsyntax as rs” (‘rs’ or any other alias).
Even though the bug is in SR12 and not the script the solution is still to modify the script since in this context the 1st import doesn’t make sense. So to fix:
Thanks.
I trust this newfound knowledge will allow you to include a very specific error message with suggested corrective action when this situation is detected?
but it appears “import rhinoscript.geometry” also needs to be removed before “import rhinoscriptsyntax as rs”. Removing userinterface alone was not enough to get mine to work.
That’s right. Just don’t use any of the import rhinoscript.userinterface import rhinoscript.geometry import rhinoscript.* ...
modules and just use import rhinoscriptsyntax as rs
instead.