The attribute dictionaries of layers lost, when I import a skp file

When I import a skp file, the attribute dictionaries of layers in the skp file.

layer = Sketchup.active_model.layers.add 'test_layer'
layer.set_attribute 'Test', 'attr', 'is_me'
Sketchup.active_model.entities.to_a[0].layer = layer
puts "layer attr : #{layer.get_attribute('Test', 'attr')}"

file_path = 'test.skp'
Sketchup.active_model.save(file_path)
Sketchup.file_new

Sketchup.active_model.definitions.load file_path
layer = Sketchup.active_model.layers['test_layer']
puts "layer attr : #{layer.get_attribute('Test', 'attr')}"

# output
# layer attr : is_me
# layer attr : 

This might be by design since you loaded the saved model as a component instead of importing it.

What happens when you use Model#import ?

1 Like

Same.

Okay, well then open an issue in the API tracker at GitHub.

1 Like