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

    Pages.erase

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 660 Views 4 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.
    • thomthomT Offline
      thomthom
      last edited by

      It's probably the indexed being shifted around when you delete the pages.

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Just tried it, if you convert the pages collection to an array first it works.
        Sketchup.active_model.pages.to_a.each { |p| Sketchup.active_model.pages.erase(p) }

        But doing so, the bar where the tabs used to be is still there, even though it's empty. It should disappear.


        pages.png

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          you are iterating through the pages object with pages.each. And then on each loop, you are deleting an element from the pages object with pages.erase( e ). So deleting objects from the collection you are iterating over will cause problems like that.

          Instead of iterating over the pages object, turn it into an array of page objects. So just change your code to this:

          model.pages.***to_a***.each{|e| model.pages.erase(e)}

          Then you are iterating over an array and erasing from the page object. So you are working on two separate objects, and avoiding any clashes.

          Did that make any sense?

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            Of course thom beat me to it - twice!

            Interseting, it does leave the bar behind....

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @chris fullmer said:

              Of course thom beat me to it - twice!

              Where's the point and make fun smiley..?

              @chris fullmer said:

              Interseting, it does leave the bar behind....

              I filed a bug report on this.
              Would be nice if we found a workaround to force the bar to refresh and disappear though...

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @chris fullmer said:

                you are iterating through the pages object with pages.each. And then on each loop, you are deleting an element from the pages object with pages.erase( e ). So deleting objects from the collection you are iterating over will cause problems like that.

                Is this a Ruby bug? It's somewhat unexpected. I'd expect the .each to be able to keep track of the content it iterates.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  On a PC only, if you add this line before erasing the scene-tabs it will toggles their bar's visibility - if they are off it will switch the bar on though...

                  Sketchup.send_action 10534
                  

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @tig said:

                    On a PC only, if you add this line before erasing the scene-tabs it will toggles their bar's visibility - if they are off it will switch the bar on though...

                    Sketchup.send_action 10534
                    

                    With the unfortunate side-effect that when you later adds pages they are still hidden. πŸ˜•

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      @thomthom said:

                      @tig said:

                      On a PC only, if you add this line before erasing the scene-tabs it will toggles their bar's visibility - if they are off it will switch the bar on though...

                      Sketchup.send_action 10534
                      

                      With the unfortunate side-effect that when you later adds pages they are still hidden. πŸ˜•

                      BUT the View menu does allow you to switch them back to being visible... πŸ˜‰

                      TIG

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

                        Cheers guys, that makes sense πŸ‘

                        http://remusrendering.wordpress.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