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

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

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 5 Posters 361 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.
    • T Offline
      Trogluddite
      last edited by

      Hi there, coders.

      I've just taken down a new Ruby plugin download because of reports that it was not working for some people at all, though I don't seem to be able to break it on my own system.

      It's pretty much my first experiment with creating geometry and groups, so no doubt this is just down to my inexperience.
      What should happen, is that the user is asked for some basic dimensions, and then a very simple grid is drawn on the ground plane, with all geometry contained within a named group.
      When I test here, on two different machines (SU8, WinXP), it works flawlessly - (so long as I type sensible values, I realise some input validation may be in order).

      However, other users have reported that no geometry or group is produced at all - though nothing 'fatal' like a bug splat or damage to exisiting geometry (phew!).

      Tile Grid.rb
      Usage instructions and correct behaviour are documented in the Ruby header.

      Thanks in advance for help and insights - I don't want to take the next step into more complex geometry until I'm sure I'm doing these simple things correctly!!

      1 Reply Last reply Reply Quote 0
      • 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