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

    Deleting all hidden geometry

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 6 Posters 17.4k Views 6 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.
    • E Offline
      ericschimel
      last edited by

      Being a bit of a rookie at Ruby, does anyone out there know if its possible to write a script that would select, and delete all hidden geometry from a model?

      -Eric
      http://plugin.sketchthis.net
      Sketchup Kitchen Design Plugin
      Custom Models

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

        Untested, but I think this should work. (SU7)

        
        Sketchup.active_model.start_operation('Erase all Hidden geometry', true)
        ents = []
        Sketchup.active_model.entities.each { |e|
          ents << if e.hidden? || e.layer.hidden?
        }
        Sketchup.active_model.entities.erase_entities(ents)
        Sketchup.active_model.definitions.each { |d|
          next if d.image?
          ents = []
          d.entities.each { |e|
            ents << if e.hidden? || e.layer.hidden?
          }
          d.entities.erase_entities(ents)
        }
        Sketchup.active_model.commit_operation
        
        

        Not sure if you also count Soft edges as 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

          It'd be quite easy to do... BUT... if something is 'connected' to other stuff you'd get unexpected problems.

          For example, if a hidden Edge is forming a visible Face then erasing the Edge erases the Face too ! Which you'd probably NOT want ??

          Exactly what 'Hidden Geometry' are we talking about here ? Hidden Groups/Instances, or other hidden 'raw geometry' like Edges/Faces?

          If it's 'all' of these then you'll need to trap for connectivity across the hidden/visible divide - like my Faced-Edge example...

          If it's stuff on a 'hidden' layer then cross connectivity still applies - there's 'hidden-entities' and entities on 'hidden-layers' - two separate things with similar outcomes...

          Please give us a bit more detail - then it'd be relatively easy to do... but the why is the most important part... So we could tailor the outcome to what you want... ❓

          TIG

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

            I suppose it could check each edge before deleting to test if it is connected to a visible face. It is is, then instead of deleting the edge, it should probably just unhide it. That might work for edges.

            Chris

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

            1 Reply Last reply Reply Quote 0
            • E Offline
              ericschimel
              last edited by

              Wow! I was just looking to see if that was even possible, I didn't mean for you guys to go and do half the work for me! I really appreciate it though!!

              Here is what I am trying to accomplish:

              I have some custom DC's that I use to make models with... I want to be able to send these models out, but I don't want the people I am sending them to to have the DC's.........

              I am basically trying to see if its possible to write a script that will delete all hidden geometry in the model (As there a lot of options in my DC's that hide, and unhide things) AND I would like the script to explode the entire model down to raw geometry (this part I already know is possible)

              I would obviously do a SAVE AS right before I did this, so I could edit my original model... Perhaps Ruby could save the file for me.... (FILENAME_EXPLODED.SKP)

              -Eric
              http://plugin.sketchthis.net
              Sketchup Kitchen Design Plugin
              Custom Models

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

                model.save
                http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/model.html#save

                So it's be

                • Save Model As
                • Erase all hidden Components (All Components in DC's only?)
                • Kaboooom!
                • Save

                ?

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

                1 Reply Last reply Reply Quote 0
                • E Offline
                  ericschimel
                  last edited by

                  You've pretty much got it!

                  My hope is, after all the hidden geometry is deleted, that the DC's don't get whacky before they are exploded...

                  -Eric
                  http://plugin.sketchthis.net
                  Sketchup Kitchen Design Plugin
                  Custom Models

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

                    hmm... Maybe removing the DC attributes before erasing..?

                    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

                      But only remove components located inside DCs?

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

                      1 Reply Last reply Reply Quote 0
                      • E Offline
                        ericschimel
                        last edited by

                        Removing the hidden ones just inside the DC's would be nice if the script could be that smart... Not necessary though... It could just delete all hidden geometry in the model...

                        Do you think there is a way to make a plugin that would strip DC's of all their "smartness"?

                        -Eric
                        http://plugin.sketchthis.net
                        Sketchup Kitchen Design Plugin
                        Custom Models

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

                          It's possible to remove the attribute_dictionaries, yes. It's from them you can detect if a component is a DC.
                          But I'm not sure about any observers attached to the DC. Maybe there's some hidden API to control that..?

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

                          1 Reply Last reply Reply Quote 0
                          • E Offline
                            ericschimel
                            last edited by

                            That would be nice if you could do that....

                            However, simply exploding everything in the model should cause the DC's to lose all their attributes anyway...

                            As long as I can get rid of the hidden geometry, which shows itself when exploded, I would be good...

                            -Eric
                            http://plugin.sketchthis.net
                            Sketchup Kitchen Design Plugin
                            Custom Models

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

                              @thomthom said:

                              But I'm not sure about any observers attached to the DC. Maybe there's some hidden API to control that..?

                              @unknownuser said:

                              However, simply exploding everything in the model should cause the DC's to lose all their attributes anyway...

                              I'm not 100% certain of how they work internally, but it would seem if simply exploding a DC and vaporizing the attribute dictionary caused a failure of SketchUp, it would be a major issue and would have come up already.

                              Hi

                              1 Reply Last reply Reply Quote 0
                              • E Offline
                                ericschimel
                                last edited by

                                I just realized that I would have to "Purge Unused" from the model as well to get rid of all the components...

                                I would assume that is easy to access via ruby as well....

                                -Eric
                                http://plugin.sketchthis.net
                                Sketchup Kitchen Design Plugin
                                Custom Models

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

                                  @unknownuser said:

                                  I just realized that I would have to "Purge Unused" from the model as well to get rid of all the components...

                                  I would assume that is easy to access via ruby as well....

                                  Yes.

                                  I won't have time to look at this for a few days - if any of the other scripters got a few spare minutes..?

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

                                  1 Reply Last reply Reply Quote 0
                                  • E Offline
                                    ericschimel
                                    last edited by

                                    Don't let me stop you if you want to... I was just trying to get a sense of the possibility of all of this. Im going to start researching the Ruby code site and see what I can come up with...

                                    -Eric
                                    http://plugin.sketchthis.net
                                    Sketchup Kitchen Design Plugin
                                    Custom Models

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

                                      Well, it's a nice little starter project if you're new to ruby and sketchup plugin scripting.

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

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

                                        Hello to all,

                                        12 years later... Sorry.

                                        I am working on model with a lot of DCs, and the .csv export of "attrreporter.rb" takes several time.

                                        The TomTom's solution "model.save" maybe can hepl me.

                                        Does Someone keep it safe?

                                        Thank you for your answers.

                                        Julien

                                        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