sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Hide selected objects from scenes except the active one?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 211 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.
    • renderizaR Offline
      renderiza
      last edited by

      Hi,

      I want to hide selected object from all scene except the one that is active.

      This is the code I have so far...any ideas are welcome!

      model = Sketchup.active_model
      pages = model.pages
      sel = model.selection
      
      pages.each {|page|
      
      	sel.each do |e|
      		e.hidden = true
      	end
      
      	page.update
      
      }
      

      Cheers!

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

        Perhaps something like

        ...
        pages.each {|page|
          next if page == pages.selected_page # to skip active scene
        ...
        }
        

        TIG

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          Thanks TIG but there is a problem...

          Lets say I have two scenes with two objects and I select the 1st object from 1st scene and do the script...it will work but...if I go to 2nd scene and select the 2nd object to do the script when I go to 1st scene the 1st object ends up hidden as well which it was not supposed to. (Hope this makes sense)

          Anyhow it may be that the page.update needs to first select each page before doing update. So that means I can't use your suggestion but I did find a solution... Here is the code...

          model = Sketchup.active_model
          pages = model.pages
          sel = model.selection
          c_page = pages.selected_page
          
          skip = []
          skip << c_page.name
          
          pages.each {|page|	
              pages.selected_page = page	
              if page.name != skip.first	
                  sel.each do |e|
                      e.hidden = true
                  end	
                  page.update
              end
          }
          
          page_num = 0
          pages.each {|page|
               if page.name == skip.first
                   pages.selected_page = model.pages[page_num]
                   break
               end
               page_num+=1
          }
          
          skip.clear
          

          Note: Updated the explanation a bit to fix it a little so it makes more scene hopefully. πŸ˜•

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

          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