@thomthom said:
I see an issue with this method:
It has multiple .start_operation and commit_operation inside the code flow - which will interfere with any start_operation you started yourself - since SU doesn't handle nested start_operations:
` model.start_operation
...
layer.color = 'red' # this breaks the undo stack
...
model.commit_operation`
Though, it is not related to the error you got.
Sorry, I don´t understand that.
I tried now that:
def layer_color
model = Sketchup.active_model
layer = model.layers.add "Test_Layer"
layer.color = [255,255,255]
end
if( not file_loaded?("test.rb") )
plugins_menu = UI.menu("Plugins")
plugins_menu.add_item("LayerColor") {layer_color}
end
#-----------------------------------------------------------------------------
file_loaded("test.rb")
That works without error - but the new layer has the color 102,68,0
and not 255,255,255!!!???
I test that:
def layer_color
model = Sketchup.active_model
layer = model.layers.add "Test_Layer"
layer.color = "Blue"
end
if( not file_loaded?("test.rb") )
plugins_menu = UI.menu("Plugins")
plugins_menu.add_item("LayerColor") {layer_color}
end
#-----------------------------------------------------------------------------
file_loaded("test.rb")
The same result like before - Color 102,68,0 instead of blue
Than I test that:
def layer_color
model = Sketchup.active_model
my_mat = materials.add "Ahorn"
my_mat.texture = "O;\\Sketchup\\Mat\\Ahorn.jpg"
layer = model.layers.add "Test_Layer"
layer.color = my_mat
end
if( not file_loaded?("test.rb") )
plugins_menu = UI.menu("Plugins")
plugins_menu.add_item("LayerColor") {layer_color}
end
#-----------------------------------------------------------------------------
file_loaded("test.rb")
There was no error but also no layer!!