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!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Plugin] Loose Geometry to Groups (Updated August 28, 2009)

    Scheduled Pinned Locked Moved Plugins
    36 Posts 10 Posters 37.6k Views 10 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.
    • R Offline
      RickW
      last edited by

      Chris,
      Congrats on your first script! Way to jump in and make things happen 😄
      Regarding classes and understanding them a little bit more - they are like the framework for objects. They contain the rules for behavior and parameters. When you want one of those objects, you create an instance of it. That instance will behave like other instances that share similar parameters.

      I created this (overly simple) example a long time (5 years) ago, on the old SketchUp forum. Perhaps it will help.

      As for understanding modules, let's continue with the Ball class. I like playtime with my 15-month-old son. He has several toy balls that he plays with. With him in mind, I would write the Ball class as in my linked example.

      On the other hand, my wife loves to dance. With her in mind, I would write a Ball class like this:

      class Ball
        def initialize
          #code goes here
        end
      
        def music=(style)
          #code goes here
        end
      
        def orchestra_size=(i)
          #code goes here
        end
      
        def refreshments=(good_eats)
          #code goes here
        end
      
      end # class Ball
      
      strictly_ballroom = Ball.new
      strictly_ballroom.orchestra_size=50
      strictly_ballroom.refreshments=["caviar","champagne","cheese","foie gras","hot wings"]
      etc...
      

      The problem is that both classes have the same name, but different methods and uses. A toy ball isn't likely to need refreshments or an orchestra size, and a grand ball with dancing and an orchestra isn't likely to be inflated or inclined to bounce. Yet if both files were loaded, a bizarre merger would occur where one could see bouncing ballrooms and round rubber toys stuffed with hors d'oeuvres. That's where modules come into play.

      module Toys
        class Ball
          ...etc
        end
      end
      
      module Parties
        class Ball
          ...etc
        end
      end
      
      bouncyball = Toys;;Ball.new
      grandball = Parties;;Ball.new
      

      This significantly cuts down on the possibility of conflicting classes and methods, but even then, selecting a unique module name is important.

      RickW
      [www.smustard.com](http://www.smustard.com)

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

        Chris,

        I just saw this - it doesn't do what you think it does.

        if entity.typename == ("Edge" or "Face")
        

        What does the right-hand-side of the evaluate to?

        You need to write it like this:

        
        if entity.typename == "Edge" or entity.typename == "Face"
        

        or perhaps even this:

        
        if( %w(Edge Face).include?(entity.typename))
        
        

        Hi

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

          Hmm, what does what I wrote do then? It seems to work. I was thinking that it would evaluate to a true or false depending if the typename was edge,face,component, or group (Edge or face = true, group or component = false). It seems to be working in the code, but I'm sure its just dumb luck and will probably fail in circumstances I have not tested. I'll re-write like your first example (because I don't follow what's happening in the 2nd example 😆 ). I need to look at what %w is. Thank you so much for taking the time to read through the script Jim,

          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

            ok, I think I'm getting the problem with what I wrote. I want an IF statement to essentially boil to down "if true"

            but my code

            if entity.typename == ("Edge" or "Face")
            

            is evaluating down (over the 3 steps I've written out)

            "if entity.typename == (true)"
            
            if face == true
            
            if false
            

            So I should be getting a false no matter what the 2nd half of the evaluate is, since neither true nor false == face. Am I understanding the logic flow there correctly?

            Chris

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

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

              Sorry, I tried to be too clever in my last example...

              this:

              
              ("Edge" or "Face")
              
              

              always returns "Edge" so your comparison always boils down to

              
              if entity.typename == "Edge"
              
              

              which works just fine since all_connected will pick up any connected faces.

              Hi

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

                Ohh! That makes so much sense now. I was wondering why it was working, but that explains it. But yes,it was not doing what I thought it was doing. Thanks for clearing that up Jim.

                Chris

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

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mimnbazhq
                  last edited by

                  😄

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

                    This script had a bug that I updated. I also added a counter to the status bar so that you can see the script in action. It counts the entities as it processes them so you know where it is in the process (though it is possible that the Sketchup user interface might freeze and quite showing the counter while processing large selections).

                    version 1.2 2009-08-28

                    • Fixed a major bug where the script was not working with selections.
                    • Fixed some internal coding that might make it slightly faster.
                    • Added an entity counter to the Status Bar so you can see the script working.
                    • Changed the Undo title from "Make groups" to "Loose to Groups" (this is the title that you see in the Edit > Undo command).

                    This is script is located on smustard.com at:

                    favicon

                    (www.smustard.com)

                    Chris

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

                    1 Reply Last reply Reply Quote 0
                    • bagateloB Offline
                      bagatelo
                      last edited by

                      Hi Chris Fullmer

                      Great plugin, it is very usefull.

                      Would the plugin be possible to make components instead of groups??

                      While the cat's away, the mice will play

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

                        Just edit it when the group is made and group.to_component ?

                        TIG

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

                          Yup, add that line:

                          group.to_component

                          in between lines 82 and 83 - so right after this line:

                          group = @entities.add_group(to_group)

                          Its near the bottom of the scipt. about 25 lines up from the bottom.

                          Chris

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

                          1 Reply Last reply Reply Quote 0
                          • bagateloB Offline
                            bagatelo
                            last edited by

                            works very whell, thanks

                            Add in menu plugin this option


                            Add in menu plugin this option

                            While the cat's away, the mice will play

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

                              Chris, why are you splitting the geometry processing into chunks of 1000? Is it to speed up creation?
                              do you not risk splitting groups of loose geometry?

                              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

                                Thom, yes it was an attempt to speed things up. I do not think it helped at all. I can't look at the code right now, but I was thinking that I done something to make sure I did not split up geometry......but its also possible I did not think of that 😳

                                Chris Fullmer

                                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

                                  Maybe you did, I did not decipher the code that thoroughly. Was curious if you found some speed tricks.

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

                                  1 Reply Last reply Reply Quote 0
                                  • G Offline
                                    guaucorreo
                                    last edited by

                                    hi, i played with this plugin and all was god, but now
                                    i have a bug that say in spanish "AJUSTA LA HORA", in english its something like "CHANGE THE CLOCK TIME"
                                    ????????WHY

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

                                      @guaucorreo said:

                                      hi, i played with this plugin and all was god, but now
                                      i have a bug that say in spanish "AJUSTA LA HORA", in english its something like "CHANGE THE CLOCK TIME"
                                      ????????WHY

                                      Can you post a screenshot of your error message?

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

                                      1 Reply Last reply Reply Quote 0
                                      • G Offline
                                        guaucorreo
                                        last edited by

                                        i have the "loose geometry to components"

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

                                          @guaucorreo said:

                                          i have the "loose geometry to components"

                                          The error isn't from this plugin. The plugin is all English, and there is nothing in its code that mess with the clock.

                                          If you post a screenshot of the error message we might be able to determine what it is.

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

                                          1 Reply Last reply Reply Quote 0
                                          • G Offline
                                            guaucorreo
                                            last edited by

                                            after three seconds of runing the plugin send me this message "ajusta la hora"


                                            ajusta la hora.jpg

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

                                            Advertisement