How to get edge/line color?
-
Hi all,
Using Ruby, is it possible to retrieve the color of an Edge object?
I am working on a plugin and I have no idea how to access this information from the code.
Any help is appreciated
-
-
View the API for Edge, but there isn't anything about colors there.
-
Realize an Edge is a Drawingelement, and so inherits the methods of Drawing element.
-
Find that Drawingelements have a material property, which returns a Material.
-
See that a Material has a color property.
In Short, with a single edge selected..
some_edge = Sketchup.active_model.selection[0] edge_color = some_edge.material.colorBut, if the edge has no material, this will give an error because some_edge.material will return
nil. So you should check the Edge has a material before asking for the color. -
-
Hi Jim,
Thanks for pointing me that way but it appears that the material for my lines is null/nil.
I see if I go to Windows->Styles, then click on Edit in the newly opened window, I can change line colours from there.
Is this information exposed through a different API maybe?
-
@bigstink said:
Is this information exposed through a different API maybe?
Yes, Style settings are accessed in the Hash-like RenderingOptions. You can view all the RendingOptions using this line in the Ruby window.
Sketchup.active_model.rendering_options.each {|k, v| puts "#{k} = #{v}"}There does not appear to be a key for an "EdgeColor"
-
Ah, it is the
ForegroundColorkey. -
Perfect, those rendering options will come in handy!
This works great, thanks Jim
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