[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.entities
the 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.entities
withgroup.entities
.There would be errors pointing out that
group.definition
was 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: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 -
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
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.)
-
Thanks Dan, I'll go check that out.
Advertisement