Layer color opacity via Ruby
-
Hi, i cant set layer color opacity via Ruby script:
layer = layers.add "newlayer" layer.color = "red" layer.alpha = 255 //tried 0.1 and other values
when layer created opacity is always 100. Any thoughts?
Thanks -
It's not currently possible.
Only a layer's color - RGB - is changeable in Ruby.Sadly no Alpha [or Textures] are possible.
One 'trick' is to make a SKP containing all of the Layers you want to use, each with manually assigned colors, and with transparencies and textures if desired.
Remember to include a guide-point at the origin so it's usable later.
Now in your Ruby code load that SKP as a component definition.
If you do it inside a start_operation...commit block and use compdefn.entities.clear! then the loaded component is deleted but its imported layers remain - although later on they'll purge if unused.Now you can use these layers by name.
Depending to what you want to do you can also rename an imported layer if desired...
Advertisement