[Ruby] Help - Sometimes a group, sometimes not.
-
Have you asked them to keep the Ruby Console open and report back any messages that might appear?
-
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.
-
group.definition.entitiesthe API doesn't providegroup.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.entitieswithgroup.entities.There would be errors pointing out that
group.definitionwas not a valid method if the users had the Ruby Console open. -
@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.
-
@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...... "

-
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:inadd_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 -
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!
-
@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! -
@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
retrykeyword 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.)
-
Thanks Dan, I'll go check that out.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement