Here is a script in IronPyron 2 that work fine and that i used to change the color of a box.
Here is the same script in New python 3 (Rhino 8)
Any clues on this error?
Here is a script in IronPyron 2 that work fine and that i used to change the color of a box.
Here is the same script in New python 3 (Rhino 8)
Any clues on this error?
Yes, apparently you can no longer do that - it says that the ‘color’ object returned by rs.ObjectColor()
is not subscriptible - i.e. you can not parse it as a list.
If you run this in Py3:
import rhinoscriptsyntax as rs
obj=rs.GetObject()
color=rs.ObjectColor(obj)
for i in range(3):
print(color[i])
You get:
TypeError: 'Color' object is not subscriptable
Whereas if you run it in Py2, you get the R,G,B returned
In Py3 you will need to do this - which also works in Py2:
import rhinoscriptsyntax as rs
obj=rs.GetObject()
color=rs.ObjectColor(obj)
rs.ObjectColor(obj,[color.R,color.G,color.B,25])
I do not know if this is something that is/will be considered a bug, there are lots of these little things that work differently in Py2 and Py3.
I believe @eirannejad is investigating ways to support this syntax in the future.