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...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement