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

    Bug Splat on erase!

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 3 Posters 418 Views 3 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      http://code.google.com/apis/sketchup/docs/ourdoc/modelobserver.html

      Read the Introduction section:

      @unknownuser said:

      Performing any edit operations of your own (such as modifying the model) inside the observer callback should be avoided, as it could cause crashes or model corruption.

      if Drawingelement#erase! causes a BugSplat!, try instead:

      class MyModelObserver1 < Sketchup;;ModelObserver
         def onPreSaveModel(model)
            selection = model.selection
            unless selection.empty?
              model.active_entities.erase_entities(selection[0])
              model.active_view.refresh() 
            end
         end
      end
      
      

      ... but may not work either.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • voljankoV Offline
        voljanko
        last edited by

        Uff,your solution didn't resolved the problem(same result),but helped to understand it.
        It seems that the onPreSaveModel observer is not the real pre save observer.I would need a pre-pre save observer. 😄

        SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

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

          A SelectionObserver ?

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • voljankoV Offline
            voljanko
            last edited by

            I have a group that is generated when a tool is activated and deleted when a tool is deactivated.
            The problem is when the model is saved when a tool is active (auto save or user save).
            I don't want that group to be saved in the model,so I have implemented the onPreSaveModel observer to delete the group.
            But I cannot get rid of the BugSplat.

            SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

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


              Make sure you read (and bookmark,) these topics:

              • State of Observers — 28 February 2010
              • State of Observers Redux — 12 September 2010

              And ThomThom webpage:

              State of Google SketchUp's Observers


              @unknownuser said:

              (http://forums.sketchucation.com/viewtopic.php?f)":3um4efab]Other notes
              Another thing I learned was that doing modifications to the model on observer events can cause lots of problems.

              •If a script is doing something which trigger an event that modifies the model it will break the undo stack. I also seem that it can make SU unstable. You could potentially cause infinite loops.
              •After consulting with Scott it seems that queueing up a list of modifications to be done to the model and executing the list on ModelObserver.onTransactionCommit is the most reliable way to do it.

              I'm not here much anymore.

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

                Mat I ask what your temp group do? What is it function?
                (just wondering if there might be alternatives to creating temp geometry here - such as using view.draw for instance...)

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

                1 Reply Last reply Reply Quote 0
                • voljankoV Offline
                  voljanko
                  last edited by

                  @thomthom said:

                  Mat I ask what your temp group do? What is it function?

                  Im using it to highlight some surfaces ,because I can draw only lines (and points and text) with view.draw.

                  Is there any samples of using the ModelObserver.onTransactionCommit and other onTransaction functions?
                  I cannot figured out what are they for.

                  SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

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

                    @voljanko said:

                    @thomthom said:

                    Mat I ask what your temp group do? What is it function?

                    Im using it to highlight some surfaces ,because I can draw only lines (and points and text) with view.draw.

                    Incorrect - you can draw filled shapes with view.draw . GL_TRIANGLES, GL_TRIANGLE_STRIP,
                    GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON will let you do that. But note that in SU prior to version 8 the fill is always black. But as of v8 it works great. You can even use transparent fill.

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

                    1 Reply Last reply Reply Quote 0
                    • voljankoV Offline
                      voljanko
                      last edited by

                      Thank you for pointing this out,I was really stacked wit this BugSplat.
                      So, more new functions to learn. 🤓 😄

                      SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                      1 Reply Last reply Reply Quote 0
                      • voljankoV Offline
                        voljanko
                        last edited by

                        But also Dan's suggestions have positive results:
                        In the activate method of the tool I have put the

                        Sketchup.active_model.start_operation "myTool",true,true,false
                        

                        And I have put the

                        Sketchup.active_model.abort_operation
                        

                        in the deactivate method of the tool and in the onPreSaveModel model observer.
                        Now the group is disappear before saving the model.
                        Thank you both.

                        SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                        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