Attach UserData to Layer

Hi guys,

Just was curious if it is possible to attach User Data to Layer in the same way as it is possible with objects.
If yes - how can I assign and read user data from the layer with RhinoCommon?

Thanks in advance,
Dmitriy

Never tried this before, but this seems to work (you need to have a “Default” layer) :

import Rhino
import scriptcontext as sc

layers=sc.doc.Layers
layer_index=sc.doc.Layers.Find("Default",True)
layer=layers[layer_index]
layer.SetUserString("TestKey","This is a test")
layer_string=layer.GetUserString("TestKey")
print layer_string

>>>"This is a test"

–Mitch

Yes, you sure can.

Thanks.

I have a problem.
Can it support the Undo/Redo function ?

Yes, adding users strings can be undone/redone…

Thanks!

Reminds me on something I considered a bug: The command _SetUserText cannot be undone.
To repeat: Create an object, SetUserText, Undo and the object is gone.

I agree.

http://mcneel.myjetbrains.com/youtrack/issue/RH-29100