Set_attribute does not support custom classes?

I want to save custom data of custom classes in model with set_attribute:

Sketchup.active_model.set_attribute("WW", "attr1", value)

If the “value” is number/string, it works well. But If value is a Hash, I get nil from get_attribute:

val = Sketchup.active_model.get_attribute("WW", "attr1", nil)

I cannot store Hash or custom data in attribute dictionary. Any mistake I made?

According to documentation, as a list of parameters here:
AttributeDictionary l#[]=-instance_method

value can be:
Boolean, Fixnum, Float, Length, nil, String, Time, Array, Geom::Point3d, Geom::Vector3d

I’m not sure if it is the case. Someone with more experience should confirm…

Thanks dezmo.

We save data as protobuf format. It is convinent to convert binary protobuf to custom classes and reverse. But not from/to json. I want to save the binary data in model. As the AttributeDictionary document, it is not possible.

Have you tried to store the binary data as a binary string in Ruby?