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

    Sketchup.active_model.layers returns <Deleted Entity>?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 3.8k 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.
    • J Offline
      Jim
      last edited by Gábor

      I'm not sure how I did it, but calling:

      
      Sketchup.active_model.layers
      #<Deleted Entity;0xb016af8>
      
      

      I go to the Layers dialog, add some new layers - same thing. File > New == same thing.

      How in the world can the layers object become deleted, and can I do anything about it from ruby? Shouldn't it at least always contain Layer0, since it is always present?

      Thanks.

      Hi

      1 Reply Last reply Reply Quote 0
      • KrisidiousK Offline
        Krisidious
        last edited by

        what ever that sound is when you run your fingers up and down over your lips?

        blblblbblblblb....

        cuz I ain't got no clue whatcha talkin bout george....

        By: Kristoff Rand
        Home DesignerUnique House Plans

        1 Reply Last reply Reply Quote 0
        • R Offline
          RickW
          last edited by

          You can get the same thing with Sketchup.active_model.pages
          The problem usually occurs when something is assigned to a variable (ie pages=Sketchup.active_model.pages), the script is loaded (say, on SU startup), and then you start/open a new model. pages was defined with the original model, and doesn't get redefined to the new model.

          I've mentioned this to the SU crew regarding pages. I can add that you've had the same problem with layers

          RickW
          [www.smustard.com](http://www.smustard.com)

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

            On a related issue, it doesn't look like a layer's page_behavior is saved with the model.

            
            Sketchup.send_action("showRubyPanel;")
            
            UI.menu.add_item("Layers y Pages") {
               layer = Sketchup.active_model.layers.add Sketchup.active_model.layers.unique_name
               layer.page_behavior = (LAYER_HIDDEN_BY_DEFAULT|LAYER_IS_HIDDEN_ON_NEW_PAGES)
               #layer.page_behavior = LAYER_IS_HIDDEN_ON_NEW_PAGES
               #layer.page_behavior = LAYER_HIDDEN_BY_DEFAULT
               page = Sketchup.active_model.pages.add
            }
            
            UI.menu.add_item("layer behavior") {
               puts "=" * 25
               Sketchup.active_model.layers.each { |layer|
                 puts layer.page_behavior
              }
            }
            
            

            @rickw said:

            You can get the same thing with Sketchup.active_model.pages
            The problem usually occurs when something is assigned to a variable (ie pages=Sketchup.active_model.pages), the script is loaded (say, on SU startup), and then you start/open a new model. pages was defined with the original model, and doesn't get redefined to the new model.

            I've mentioned this to the SU crew regarding pages. I can add that you've had the same problem with layers.

            Hi

            1 Reply Last reply Reply Quote 0
            • R Offline
              RickW
              last edited by

              Just tried this with FlightPath (which uses LAYER_IS_HIDDEN_ON_NEW_PAGES) and it worked fine. I saved the model, started a new model, then re-opened the saved model and checked the layer.page_behavior. Everything was saved with the model.

              RickW
              [www.smustard.com](http://www.smustard.com)

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

                @rickw said:

                Just tried this with FlightPath (which uses LAYER_IS_HIDDEN_ON_NEW_PAGES) and it worked fine. I saved the model, started a new model, then re-opened the saved model and checked the layer.page_behavior. Everything was saved with the model.

                It doesn't work for my posted example. Did I do something wrong?

                Hi

                1 Reply Last reply Reply Quote 0
                • R Offline
                  RickW
                  last edited by

                  I tried your example script, and see the problem you see.

                  According to the SU ruby docs:

                  "Currently there are two behaviors defined.

                  A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility determined by one of these flags.

                  LAYER_VISIBLE_BY_DEFAULT 0x0000
                  LAYER_HIDDEN_BY_DEFAULT 0x0001"

                  The strange thing is that in commenting out different lines and trying the script again, LAYER_IS_HIDDEN_ON_NEW_PAGES is the setting that sticks - not LAYER_IS_HIDDEN_BY_DEFAULT.

                  I'll report that to the SU crew.

                  RickW
                  [www.smustard.com](http://www.smustard.com)

                  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