How to change color of several layers at once

I meant Xray actually. (Edited abovepost.)

I suppose if a layer was manually created and named say “Transparent”, then a plugin could save all layer assignments, then reassign objects to the “Transparent” layer and switch to Color By Layer mode.
Another command could reverse the process.

Yes, correct. Look at Mike’s link to the video Matt did. All layers colors set with opacity to zero and all edges and profiles off.

I saw that. But as said earlier, the Ruby API cannot change layer opacity. It can however reassign an object’s layer to one whose opacity was set transparent manually. Edges and profiles is a style setting which can be saved to a scene, but changing object’s layer assignments is a geometric change that needs an undo operation.

@dezmo
Where there is a will there is a way. If you import a carefully crafted model (as a component definition) into the active model, and the imported model contains a layer with the 0% opacity set. The layer will be added to the current model. If you then import a style with Color by Layer checked and set up a new scene for the style, well then you have it. I make no claims of ownership to this code. Please take it and improve upon it

For this demo, any objects that are selected before clicking on the the green-meanie button will be moved to the transparent layer

sw_TransparentLayer.rbz (154.1 KB)

2 Likes

Hi botomup,

Try this:

  • download attached ZIP, unzip it in your Plugins folder.

  • restart Sketchup

  • hide the layers you want to change the color

  • open the Ruby console and type: layersColor(r,g,b)
    where r, g, and b are 3 integers from 0 to 255 (the 3 RGB coordinates of the color), e.g. layersColor(255,0,0) will set the hidden layers a pure red color

  • you can also give the script any Web color name as unique argument (such as “burlywood”, “cyan”, darkgray", “aliceblue”…)
    e.g layersColor(“sandybrown”)

  • then you’ll be asked if you want to make the hidden layers visible again.
    color4Layers.zip (873 Bytes)

@sWilliams I like your idea!

However, this method allows only one “level” of opacity (0% aka full transparent) to set.
The “original” request from @DaveR: Could you add an opacity setting to apply to selected layers?"
So I would like to get some general solution… :slight_smile:

If I want to set 256 different level (as the color.alpha method “normally” do) then I need 256 different model (or one model with 256 different layer?) ready to be imported…
… but then an other issue will come: Since currently the User Interface the only way to set the opacity of the layer, you can set 101 level (0…100) with it.
Okay, this can be approximated to 256 levels, so in this case I have to create “only” 101 templates.
Then I can select the corresponding one, “move” entities into it, rename, set rgb… etc.
Not a big deal :stuck_out_tongue_winking_eye:

Probably I will study it more if I get some more spare time allocated to it. :wink:
Thanks for the code!

I appreciate that however at the time I wrote it, the thought was to make it easier to apply an opacity of 0 to all of the layer colors so that the method outlined by Matt Donley would be easier to implement.

Yea Dave, I know why are you asked… but I like the challenges, even if I did not ever used or probably I’ll never use section cut … at all. :wink:

1 Like

I’m not sure I’d have a use for an extension to do this either but then again, if it existed and I tried it out, I might find a way to use it in my work. :wink:

1 Like

I have had some time (less then I wanted…) at the weekend so worked on this for a short time…
Here we are:Dezmo_layers_color_at_once_beta.rbz (13.7 KB)

Notes:

  • No warranties! Use your own risk! Save your work before use it! Etc. … etc….
  • Not fully polished, not tested enough.
  • The user inputs are roughly checked only.
  • Best works with SU2019.
  • Not tested on MAC. (I don’t have it.)
  • My mother never talked to me in English.
  • It will work with older version /down to ~SU2015/ without dashes, and some problems with the undo stack. (I.e. there is a bug in Ruby with undo stack if loading component in earlier version of SU… search for it if you interested…)
  • Be patient! Changing alpha (opacity) of the layer could be very much time consuming, specially if there are so much entities on the questionable layer(s). You know, this plugin not really changing the opacity, but load a skp file with 101 predefined transparent layers, set all of drawing elements properties to transparent layer, remove the original layer and give the name of the original layer to the transparent one. . … then repeat…
  • Because of above: Transparency of Layer0 cannot be changed. Do that manually!
  • Changing color and dashes only should be more or less instant.

The plugin created as a workaround for a bug/missing feature in SU/Ruby:

  • to change color of several selected layers at once
  • to change opacity of the color of the layer via Ruby API

For @DaveR : “Hi might find a way to use it in his work!”
For @Sonder @botomup

…and because I like to do it.

Thanks for @DanRathbun and @sWilliams for ideas and useful info’s!

Usage:

  • Install via extension manager (EM setting should be: Unrestricted)
  • You will get a menu as well as toolbar icon. Click on it to start.
    set_layers_prop
  • If you have more than one layers the layer selection will split to pages, each with max of 20 layers.

  • Put anything else but ‘0’ to select them.
  • You can decide to change the color RGBA values individually.
    set_prop
  • The alpha value (0-255) will be converted to opacity (0-100) as on the UI. (0 is total transparent.)
  • Dashes (line types) selection similar than in the UI. (but with names)

Have a nice day!

1 Like

This looks cool and I’m getting ready to try it. Is there any chance of a way to select a bunch of layers at oat once to change the value from 0 to 1 or whatever?

Edit: First attempt: I have 20 layers including Layer 0. In the first panel I changed the value for all of the layers except Layer 0 to 1. In the second panel I changed Alpha to 255 and clicked OK.

Result: no apparent change to the transparency of the layer colors. On top of that, all layers were made visible for all scenes which is different from what I had set.

1 Like

255 is 100% opacity image

I have to check this sometime. I think it was inherited from the template what I did not created “carefully enough” . Honestly I did not think about visible for scenes … :frowning_face:
You probably can check and change the file here:
(c:\Users\username\AppData\Roaming\SketchUp\SketchUp 2019\SketchUp\Plugins\Dezmo_layers_color_at_once*0-100_opacity_layers2015.skp*)

I’ll try 0 then. :wink:

1 Like

Yea. Probably at firs will ask to start, all selected or all deselected…
(The best will be HTMLdialog… but I have lot of other thing to do… :frowning_face: )

1 Like

I think I need to “transfer” the behavior

**#page_behavior
**#visibl
e

of the original layer(s) somehow, but I have to figure out how it’s works…and if it is possible at all?!
Currently I don’t see “visible per page” method in Ruby.
Most probably it is a method on the pages (scenes), than the “simple” plugin will be extended with other simple methods… then it will not that much simple anymore… :stuck_out_tongue_winking_eye:

(BTW I did not taken into consideration the possible attached attributes to original layers as well… :frowning_face: )

1 Like

@DaveR
If you think you can test it again … :slight_smile:

Dezmo_layers_color_at_once_beta2.rbz (127.8 KB)

This version should leave (inherit) visibility of layers for all scenes as it was. (Actually, I think, all properties inherited from the original layers. :pray:t4:)

Now a dialog asking if all layers should be selected or de-selected.
image
(Probably in February I’ll find some time for HTML dialog… if there will be enough interest)

Still, all my other warning is apply ! (Save your work before try this plugin.)
Still, attributes attached to layer will be lost. (only which ones have to change the opacity )

Will do.

1 Like

Out of curiosity, how are your sorting the layer names? Surely not alphabetically.

I added it to the todo list… :blush:

1 Like