Wish - New sublayer to start with parent layer's color

Would people agree it could be convenient if new sublayers defaulted to the parent layer’s color ?
(Right now it’s always black. Prefer it to be the same or a close variant of the parent)
Clipboard-1

2 Likes

Hi Thomas -
My guess is that equally many users will still go and change the layer color of the new sublayer as they do with the current system.

I suppose “a close variant” might be more useful to some users some of the time.
I’m adding that as an additional specification to the open YT item RH-4978 - New layers random color.
Note that that particular wish item is from 2009 and I wouldn’t expect this to get any attention any time soon. You might want to look into scripting this if it’s important to you.
-wim

Would this be an ok solution to synchronize child layer colors with their parent layer colors?

layerNames = rs.LayerNames()

for layer in layerNames:
    parents = rs.ParentLayer(layer)
    if parents:
        parentColors = rs.LayerColor(parents)
        rs.LayerColor(layer, parentColors)
1 Like

Aaand you would be correct sir; even for me.
If you really pressed me for what I want and if I were to go back to my scripting days, I would
a) Determine the screen viewport color and derive a contrast factor out of the lightness value
b) Create a dialog that pairs keywords to colors.
c) Have a pertubation value for the saturation and lightness

The user might want the keyword “lights” to always produce a yellowish layer color (but still having enough contrast on the viewport) … or maybe the keyword “curves” to always produce a greyish layer color etc etc.

I would probably try it myself, but ever since I moved in a Javascript direction and developing a distaste for bracketless languages, I kind often forget about scripting.

Thanks for this quick script Martin !
It compains that rs is not defined ?

I take it after running this script it will go ahead and make all my sublayers the same color as their parent after the fact ?

1 Like

Hi Thomas - add the line

import rhinoscriptsyntax as rs

at the top of the script.

-Pascal

1 Like

I created a button for this script:

! _-RunPythonScript (

import rhinoscriptsyntax as rs

layerNames = rs.LayerNames()

for layer in layerNames:
    parents = rs.ParentLayer(layer)
    if parents:
        parentColors = rs.LayerColor(parents)
        rs.LayerColor(layer, parentColors)

)
1 Like