Material attributes in .SKM
-
Material attributes, stored in a material's attribute dictionaries, are not loaded correctly from an .SKM file.
When you apply attributes to a material, and save that material as an SKM, the attributes are saved correctly. If you rename the SKM as a zip and examine the document.xml, the attribute dictionaries are all listed, all correct.
But when you load that material into a new scene and apply it to a face, the attribute dictionaries are not restored correctly.What I've observed is that the number of dictionaries is reported correctly, but each dictionary reports it's name and keys/values as those stored only in the first dictionary. That you get multiple dictionaries with the same name seems a bug straight off the bat. Shouldn't all attributes with the same dictionary name be stored in a single dictionary?
To reproduce:
- Create a face.
- Apply any material to it (front face).
- Select that face.
- open ruby console
- in ruby console:
mat = Sketchup.active_model.selection.first.material mat.set_attribute("Dict_A", "Prop_A", "AAA") mat.set_attribute("Dict_B", "Prop_B", "BBB")
- Open Materials Dialog
- Select "In Model" materials
- Select "Save Library As"; Save where convenient
- Close and reopen SU
- Create new scene. Create a face.
- Load the library saved above.
- Apply the previous material to the face
- select the face
- in ruby console:
mat = Sketchup.active_model.selection.first.material mat.get_attribute("Dict_A", "Prop_A") mat.get_attribute("Dict_A", "Prop_A") array = mat.attribute_dictionaries.to_a array[0].name array[1].name array[0]["Prop_A"] array[1]["Prop_B"]
The results of the above ruby commands will demonstrate that the attributes are not loaded. However, the documents.xml file in the .skm clearly shows that the attributes are stored, and correct. The bug is on loading.
Advertisement