• Login
sketchucation logo sketchucation
  • Login
ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

Script to Delete Hidden Objects?

Scheduled Pinned Locked Moved Developers' Forum
17 Posts 7 Posters 1.5k Views 7 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.
  • T Offline
    Tim Danaher
    last edited by 26 Jan 2010, 09:26

    Is there one?

    The reason I ask, is because I've got a model that I'm trying to apply bomb.rb to, but every so often SU throws up the dialog 'Your recent operation has caused geometry to become merged with hidden geometry'. yesterday I set the script going when I left the house (it takes its time on complex models), and when I got back at 22:00, there was the dialog waiting for me --- the script may have been doing nothing all that time.

    As far as I know, there's no hidden geometry in my model, but there must be some tucked away in sub-groups somewhere...that's why a script like this would be so useful.

    Cheers,

    Tim

    http://vizarch.blogspot.com

    1 Reply Last reply Reply Quote 0
    • C Offline
      chrisjk
      last edited by 26 Jan 2010, 11:28

      I don't think hidden geometry is what you want to delete automatically - everything with a curve would disappear! Equally deleting hidden objects doesn't seem sensible if you have hidden rather than deleted them in the first place.

      Chris

      1 Reply Last reply Reply Quote 0
      • T Offline
        Tim Danaher
        last edited by 26 Jan 2010, 11:52

        Chris --

        Hidden objects, yes.

        Why wouldn't I want to delete them? I often forget that hidden objects are there. I've just waited nearly a day and a half for this model to explode, and the hidden objects have, naturally,become unhidden. What's more, due to the nature and size of this model, simply deleting them isn't an option. The exploded model is unmanageable in SketchUp.

        So, you see, I do want to delete hidden objects before preparing a model for export.

        Cheers,

        Tim

        http://vizarch.blogspot.com

        1 Reply Last reply Reply Quote 0
        • C Offline
          chrisjk
          last edited by 26 Jan 2010, 12:45

          Tim,

          For objects, I'd just Select All and copy it to a new window and save that as a new model version - leaving all the hidden stuff behind. You could then unhide it and inspect it for anything you might want to keep.

          Chris

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 26 Jan 2010, 12:52

            
            def erase_if_hidden()
              Sketchup.active_model.entities.to_a.each{|e|e.erase! if e.valid? and e.hidden?}
              Sketchup.active_model.definitions.each{|d|d.entities.to_a.each{|e|e.erase! if e.valid? and e.hidden?}}
            end#def
            
            

            Copy/paste this code into a text file called erase_if_hidden.rb in the Plugins folder.
            Restart Sketchup.
            To use it type erase_if_hidden + <enter> into the Ruby Console.
            Use with care since ALL hidden geometry WILL be erased - it is ruthless !!!
            Remember that if you have an edge that is hidden but it has a face that isn't then the edge's deletion could remove the face too...
            Best to switch all Layers 'on' and View > Hidden Geometry 'on' before using this just to check what is actually hidden...
            πŸ€“

            TIG

            1 Reply Last reply Reply Quote 0
            • T Offline
              Tim Danaher
              last edited by 26 Jan 2010, 13:27

              TIG --

              You da man!

              Cheers, Matey...

              Chris --

              So, would that work for hidden objects that are inside other groups and components?

              Cheers,

              Tim

              http://vizarch.blogspot.com

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 26 Jan 2010, 13:52

                @tim danaher said:

                TIG --

                You da man!

                Cheers, Matey...

                Chris --

                So, would that work for hidden objects that are inside other groups and components?

                Copy/paste will carry over hidden stuff that's inside definitions.
                My ruby erases absolutely ALL hidden entities - even inside groups/components etc... πŸ‘Š

                TIG

                1 Reply Last reply Reply Quote 0
                • C Offline
                  chrisjk
                  last edited by 26 Jan 2010, 13:58

                  Um..... No 😳

                  Chris

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    Mike Lucey
                    last edited by 26 Jan 2010, 13:59

                    Tim, Let us know how you get on with TIG's solution. Thanks TIG πŸ‘

                    Support us so we can support you! Upgrade to Premium Membership!

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      remus
                      last edited by 26 Jan 2010, 15:50

                      Wont that wreak havoc if youve got any hidden lines?

                      http://remusrendering.wordpress.com/

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 26 Jan 2010, 16:36

                        @remus said:

                        Won't that wreak havoc if you've got any hidden lines?

                        YES - that's why I heavily caveated it - HE wants to do it, so on his head be it... πŸ‘Š

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          cjthompson
                          last edited by 26 Jan 2010, 16:41

                          Why not make it select all hidden entities? That way, he can see what is hidden, and then just press the delete key.

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 26 Jan 2010, 17:08

                            @cjthompson said:

                            Why not make it select all hidden entities? That way, he can see what is hidden, and then just press the delete key.

                            Some might be inside instances and erasing across entities-sets might bugsplat ❓

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • Chris FullmerC Offline
                              Chris Fullmer
                              last edited by 26 Jan 2010, 17:11

                              Would it be better to just move all geometry to layer 0 first, then delete all other layers.

                              Then there should not be this conflict, yeah?

                              Chris

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

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                Tim Danaher
                                last edited by 27 Jan 2010, 09:35

                                Mike --

                                Will do... (if this file ever gets exploded).

                                Seriously, though, what an arseache.

                                Before I ran bomb.rb, I Unhid All, so there would be NO hidden geometry, but I'm stll getting these 'Your recent operation has caused geometry to become merged with hidden geometry'. How, if there's no hidden geometry?

                                And what's more, I'm also getting 'Your recent operation has caused geometry to become merged with geometry on a hidden layer'.

                                Now, here's a clue: I DON'T USE LAYERS. The only layer that there can be in my model is Layer 0, which is visible by default. I don't think the problem is with bomb.rb, it's some change made to the app itself.

                                Oh, and I only got TIG's script after I started the current Explode All operation (at 2 o'clock yesterday arvo).

                                Right. It's just finished.

                                This is what I got from the Ruby console:

                                erase_if_hidden
                                Error: #<NameError: undefined local variable or method `erase_if_hidden' for main:Object>
                                (eval)

                                edit: Oh, and this from the Load Error window:

                                ^Error Loading File erase_if_hidden.rb
                                /Library/Application Support/Google SketchUp 7/SketchUp/Plugins/erase_if_hidden.rb:1: parse error, unexpected tCONSTANT, expecting kEND
                                def erase_if_hidden()
                                Sketchup.active_model.entities.to_a.each{|e|e.erase! if e.valid? and e.hidden?}
                                Sketchup.active_model.definitions.each{|d|d.entities.to_a.each{|e|e.erase! if e.valid? and e.hidden?}}
                                end#def

                                Cheers,

                                Tim

                                http://vizarch.blogspot.com

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 27 Jan 2010, 09:49

                                  The file must be made with a plain-text editor [like Notepad.exe - don't know what that is on a Mac] NOT a word-processor ! I suspect hidden characters - here's the thing ready made erase_if_hidden.rb

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    Tim Danaher
                                    last edited by 27 Jan 2010, 12:52

                                    Cheers, TIG --

                                    I d/l'ed your file and put it in the plugins folder, and I'm happy to report it does exactly what it says on the tin!!!

                                    Cheers,

                                    Tim

                                    http://vizarch.blogspot.com

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

                                    Advertisement