Remove layer doesn't work?!
-
hi
sorry if this is a simple query, but it has me stuck.
I've added a layer to my model with
Sketchup.active_model.layers.add("test")
which works fine. The API reference says this should remove it,
Sketchup.active_model.layers.remove("test", true)
but it errors
Error; #<NoMethodError; undefined method `remove' for #<Sketchup;;Layers;0xc8649c4>> (eval);81
anyone got any bright ideas?!
thanks
bob -
Layers.remove
is new in SketchUp 2015.
The API docs show the version of SketchUp methods were introduced.Prior to version 15, you need to do it using
Layers.purge_unused
after moving or deleting any geometry on that Layer.TIG posted some code here: http://sketchucation.com/forums/viewtopic.php?p=166985#p166985
-
thanks Jim, I hadn't spotted the 2015+ in the docs
I have (hopefully) one more layer question. Is it possible to set the layer opacity and then turn on "color by layer"?
thanks again
-
For Color by Layer, see the Rendering Options[1]
Sketchup.active_model.rendering_options['DisplayColorByLayer'] = true
I do not think the transparency can be set from Ruby.
[1] http://www.sketchup.com/intl/en/developer/docs/ourdoc/renderingoptions
-
Jim is correct.
If, via Ruby, you give a layer a color with transparency it is ignored and it renders opaque.
Sp currently you can only change a layer's color through the API - there is no alpha OR texture support within the API, although of course you can do both of those manually...
Advertisement