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

    Entities.intersect_with crash

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 4 Posters 263 Views 4 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.
    • K Offline
      kwalkerman
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        You appear to be trying to intersect a group with itself.

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          @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 the rescue 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.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • K Offline
            kwalkerman
            last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @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.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                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)
                

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • K Offline
                  kwalkerman
                  last edited by

                  sdmitch - this works! No more bugsplats for now!

                  Thanks,

                  --
                  karen

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @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!

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • Dan RathbunD Offline
                      Dan Rathbun
                      last edited by

                      .. well, a group IS considered a single entity.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • K Offline
                        kwalkerman
                        last edited by

                        @unknownuser said:

                        ?? The API docs really need to expand with more info on this method!

                        yeah - most confusing method in the API!

                        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