sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to set page index?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 2 Posters 263 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.
    • PixeroP Offline
      Pixero
      last edited by Pixero

      What is the correct way of setting the index and name with "pages.add" ?
      I want to inset a new page at a certain position.

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

        Jan,

        I haven't tested, but if the new pages gets added after the "current" page, you could set the current page before adding the new page?

        Hi

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          I'm not sure that would work in this perticular case.
          The docs says:

          @unknownuser said:

          If index is given, it specifies the position in the page list that the new page is added. Otherwise the new page is added to the end.

          name The name of the specific page.
          flags (optional) Bit flags in integer form.
          index (optional) Index of where to inset.

          So if I want to add a page, give it a name AND a index what would be the correct syntax?

          pages.add "name" ??????

          1 Reply Last reply Reply Quote 0
          • PixeroP Offline
            Pixero
            last edited by

            Really, no one knows this?

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

              I'm not how to derive the value for the second argument (flags) is used for - 0 works but it's not what you want. I'll need to see if I can find that...

              
              index = 0
              model = Sketchup.active_model
              pages = model.pages
              pages.add("Page Name", 0, index)
              
              

              You may need to go through each page property and set them.

              Hi

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

                Ok, I found the flags:

                
                Object.constants.grep /^pag/i
                ["PAGE_USE_SECTION_PLANES", "PAGE_USE_ALL", "PAGE_NO_CAMERA", "PAGE_USE_CAMERA", "PAGE_USE_RENDERING_OPTIONS", "PAGE_USE_SHADOWINFO", "PAGE_USE_SKETCHCS", "PAGE_USE_HIDDEN", "PAGE_USE_LAYER_VISIBILITY"]
                
                

                And it looks like PAGE_USE_ALL will do it if you want the default of All Enabled.

                
                model = Sketchup.active_model
                pages = model.pages
                index = 0
                page = pages.add("New Page", PAGE_USE_ALL, index)
                
                

                If you want to pick and choose which options, bitwise OR ( | ) the options together:

                
                model = Sketchup.active_model
                pages = model.pages
                index = 0
                page = pages.add("New Page", (PAGE_USE_HIDDEN|PAGE_USE_CAMERA), index)
                
                

                Hi

                1 Reply Last reply Reply Quote 0
                • PixeroP Offline
                  Pixero
                  last edited by

                  Thanks, will try this.

                  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