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

    [Ruby] Help - Sometimes a group, sometimes not.

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 512 Views 5 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.
    • thomthomT Offline
      thomthom
      last edited by

      Have you asked them to keep the Ruby Console open and report back any messages that might appear?

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

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        The problem for me was line 40, grp_ents = group.definition.entities. Components have definitions but groups do not even though they may appear in the definitions list. Changing the statement to grp_ents = group.entities allowed the plugin to run.

        Also Ruby doesn't like spaces in from of '(' so all of the Geom::Point3d.new (...) should have the space removed.

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

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

          group.definition.entities the API doesn't provide group.definition. However, some plugins have added this shortcut method - which is why it works.

          There are ways to get the group definition - but you don't need that.

          Replace group.definition.entities with group.entities.

          There would be errors pointing out that group.definition was not a valid method if the users had the Ruby Console open.

          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

            @sdmitch said:

            Components have definitions but groups do not even though they may appear in the definitions list.

            Groups do have definitions - but they lack the method to obtain it in the same way as component instances.

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              Trogluddite
              last edited by

              @thomthom said:

              have you asked them to keep the Ruby Console open and report back any messages that might appear?

              [FacePalm] 😳
              Thanks for the prod, ThomThom - why is it always the most obvious things that I forget?! More caffeine required, I think!

              And many thanks to you and sdmitch πŸ˜„
              I still can't believe how fast those "reply to your post" e-mails go 'ping, ping, ping', I barely had time to make a coffee!

              Indeed, now that I look at the API docs again, I see my schoolboy error. I started out using a component, and then decided to change to a group to avoid browser clutter - lazy bones using find/replace instead of RTFM!!

              "Check the console, check the console, check the console, check...... " πŸ˜‰

              1 Reply Last reply Reply Quote 0
              • BoxB Offline
                Box
                last edited by

                I don't understand anything anyone has written in this thread so I can't tell if you solved it but this is the error I get if you want it.

                @unknownuser said:

                Error: #<NoMethodError: undefined method definition' for #<Sketchup::Group:0x91d8c20>> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/Tile Grid.rb:40:in add_tile_grid'
                C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/Tile Grid.rb:80
                C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/Tile Grid.rb:40:in `call'
                C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/Tile Grid.rb:40

                1 Reply Last reply Reply Quote 0
                • T Offline
                  Trogluddite
                  last edited by

                  PS) And thanks to Dan Rathburn too - I was just reading his excellent advice on catching errors inside an undo commit operation when those replies came in. So now I can make invalid input values behave more robustly too!
                  Oh, what a grand place this is! πŸŽ‰

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    Trogluddite
                    last edited by

                    @box said:

                    this is the error I get if you want it

                    Thanks - yes, that would have told me just what I needed to know, if only I had had the good sense enough to ask!
                    Fixed version now popped backed into the original thread, with thankyou's all round!

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      @trogluddite said:

                      ... So now I can make invalid input values behave more robustly too! ...

                      Look at the global inputbox() method in "Tools/sketchup.rb"

                      It is an [simple] example of using Ruby's retry keyword to force valid input.

                      (Although it really should not have been made a global method, .. but that's an old peeve. It would be better to copy it into your own module namespace.)

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        Trogluddite
                        last edited by

                        Thanks Dan, I'll go check that out.

                        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