Entities.intersect_with crash
-
Hi - I'm having trouble with "entities.intersect_with"
The code I'm using is:
g.entities.intersect_with(false,g.transformation,g.entities,g.transformation,false,g.entities.to_a)
where g is a group inside the Sketchup.active_model.entities collection.
Most of the time my code progresses without issues, but sometimes it crashes and I can't figure out why.
I can stop my code before this line and then manually intersect by selecting faces - without crashing SU. I have noticed that in cases where Sketchup crashes, when I manually intersect I end up with hidden lines on the intersected faces - as if the face is not planar. However, I can erase these lines without erasing the face.
Any ideas?
Thanks.
--
Karen -
You appear to be trying to intersect a group with itself.
-
@kwalkerman said:
..., but sometimes it crashes and I can't figure out why.
Well wrap it a
begin
..rescue
..end
block... actually add an undo operation to that block, with an
abort_operation()
inside therescue
clause.Save any
Exception
info to a logfile, from the rescue block.rescue Exception => e File.open('whoops.txt','w+') { puts e.inspect; puts e.backtrace; } Sketchup.active_model.abort_operation() UI.messagebox("Intersect Error! Check 'whoops.txt' log.") end
Otherwise, it seems weird that your code sample is intersecting the group's
entities
with itself. -
Yes, I am intersecting the groups entities with itself - this is so that I get lines at any location where two faces intersect.
Regarding the crash - I don't think I was clear. Ruby doesn't crash - Sketchup crashes, so I don't think a begin... rescue block would help.
Is there any other way to intersect faces in a collection?
-
@kwalkerman said:
... Ruby doesn't crash - Sketchup crashes, so I don't think a
begin
...rescue
block would help.Well, It can't hurt. And it is best practice.
The undo operation, combined with the
begin
...rescue
block, is designed to help protect the model from corruption.And ya' never know, it might just log a StackOverflow or some error just before SketchUp poops out.
-
Changing the g.entities.to_a at the end of the code statement to just g worked for me without a bug splat
g.entities.intersect_with(false,g.transformation,g.entities,g.transformation,false,g)
-
sdmitch - this works! No more bugsplats for now!
Thanks,
--
karen -
@sdmitch said:
Changing the g.entities.to_a at the end of the code statement to just g worked for me without a bug splat
g.entities.intersect_with(false,g.transformation,g.entities,g.transformation,false,g)
?? The API docs really need to expand with more info on this method!
-
.. well, a group IS considered a single entity.
-
@unknownuser said:
?? The API docs really need to expand with more info on this method!
yeah - most confusing method in the API!
Advertisement