• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Remove layer doesn't work?!

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 491 Views 3 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.
  • S Offline
    sdafasdf
    last edited by 6 Dec 2014, 08:13

    hi

    sorry if this is a simple query, but it has me stuck.

    I've added a layer to my model with

    Sketchup.active_model.layers.add("test")
    

    which works fine. The API reference says this should remove it,

    Sketchup.active_model.layers.remove("test", true)
    

    but it errors

    Error; #<NoMethodError; undefined method `remove' for #<Sketchup;;Layers;0xc8649c4>>
    (eval);81
    

    anyone got any bright ideas?!

    thanks
    bob

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 6 Dec 2014, 08:41

      Layers.remove is new in SketchUp 2015.
      The API docs show the version of SketchUp methods were introduced.

      Prior to version 15, you need to do it using Layers.purge_unused after moving or deleting any geometry on that Layer.

      TIG posted some code here: http://sketchucation.com/forums/viewtopic.php?p=166985#p166985

      Hi

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdafasdf
        last edited by 7 Dec 2014, 08:22

        thanks Jim, I hadn't spotted the 2015+ in the docs 😳

        I have (hopefully) one more layer question. Is it possible to set the layer opacity and then turn on "color by layer"?

        thanks again

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by 7 Dec 2014, 10:47

          For Color by Layer, see the Rendering Options[1]

          
          Sketchup.active_model.rendering_options['DisplayColorByLayer'] = true
          
          

          I do not think the transparency can be set from Ruby.

          [1] http://www.sketchup.com/intl/en/developer/docs/ourdoc/renderingoptions

          Hi

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 7 Dec 2014, 11:47

            Jim is correct.
            If, via Ruby, you give a layer a color with transparency it is ignored and it renders opaque.
            Sp currently you can only change a layer's color through the API - there is no alpha OR texture support within the API, although of course you can do both of those manually...

            TIG

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

            Advertisement