Bugsplat in Sketchup 2017 when manipulating groups
-
I'm the author of the SunHours extension. Using the extension in Sketchup 2017 causes it to crash. Many users have emailed me about this but there's not much I can do since the bug is in Sketchup. I've narrowed the problem down to a minimal snippet of code which causes the crash:
model = Sketchup.active_model model.start_operation("BOOM", true) entities = model.entities face = entities.to_a.select{ |ent| ent.is_a? Sketchup;;Face }[0] group = entities.add_group([face]) group2 = entities.add_group([group]) group.explode face = group2.entities.to_a.select{ |ent| ent.is_a? Sketchup;;Face }[0] group2.explode entities.add_group([face]) model.commit_operation
Creating a model with a single face and running that snippet in the Ruby Console will crash Sketchup with a bugsplat. Removing any single line (I think, I may have missed one) of the snippet will prevent the crash. I know the code looks strange and contrived but it is derived from real code (with lots of things in between removed) and the structure of creating and exploding groups is necessary.
Please let me know if an update is released which fixes this issue.
I'm on OSX but I don't think this is OS dependent.
-
Unfortunately v2017 changes the way references can be got and reused.
A few pointers...
Use:entities = model.**active_**entities
Also you can 'grep' to filter many kinds of 'collections' thus:
puts face = entities.grep(Sketchup::Face)[0] return nil unless face
The 'face' reference is lost in v2017 after the 'explode', instead consider this...
group.explode puts face = group2.explode.grep(Sketchup::Face)[0]
Now 'face' is a different, but valid, reference...
I added the 'puts' to print the references in the Ruby Console.
In < v2017 they should be the same, but in v2017 they will differ.
This issue has meant that many authors have had to recode some of their plugins to accommodate the changes...
Advertisement