sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    How to get edge/line color?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 377 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bigstink
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        1. View the API for Edge, but there isn't anything about colors there.

        2. Realize an Edge is a Drawingelement, and so inherits the methods of Drawing element.

        3. Find that Drawingelements have a material property, which returns a Material.

        4. 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.color

        But, 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

        1 Reply Last reply Reply Quote 0
        • B Offline
          bigstink
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            @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"

            Hi

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              Ah, it is the ForegroundColor key.

              Hi

              1 Reply Last reply Reply Quote 0
              • B Offline
                bigstink
                last edited by

                Perfect, those rendering options will come in handy!

                This works great, thanks Jim

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement