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

    Determining when a model has changed

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 50 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.
    • Al HartA Offline
      Al Hart
      last edited by

      We have some code we want to run whenever a user starts a function, but the model has changed since the last time it was started.

      • Either by using SketchUp "New", or "Open", or by adding new geometry.

      We have been using two "tricks" to determine if the model has changed since we last checked it.

      1. We write a UUID as an attribute to the model, then check to see if the UUID has changed.
      • that catches New and Open. But can get messed up if the model is saved with a new name, for example, and changed, saved, and then then first model is loaded, so we added #2.
      1. We remember the name and path of the model and check it to see if it has changed.

      2. We plan to remember the number of entities in the model as well, so we can tell when new entities have been added. (But, of course, this will not catch those cases where one entity was deleted and one new entity was added)

      It does not hurt for us to run the routine we run when the model has changed - but it can take a few seconds, (or longer), so we don't want to run it too often.

      Does anyone have any ideas on how to determine if the model has been changed?

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        https://developers.google.com/sketchup/docs/ourdoc/model#modified?

        The model.modified? method determines if the Model has been modified since the last save.

        TIG

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          The model.modified? method determines if the Model has been modified since the last save.[/quote]

          Thanks for the quick response TIG.

          That would work if there was a "saved" Observer, (so I could remember that the model had been saved, and set a semiphore to remember that it had been saved) (It wouldn't hurt to re-run my routine once per save)

          Also, the changes I make after performing my check for changes would set the modified? tag, and confuse me. (and I don't want to reset the modified? value, or to save the model)

          Al Hart

          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

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

            @al hart said:

            @tig said:

            The model.modified? method determines if the Model has been modified since the last save.

            That would work if there was a "saved" Observer, ...

            The "saved" callbacks are in the Sketchup::ModelObserver class (where they should be, because there can be more than one model open on the Mac. But you can write a generic model observer that handles all open model instances, since the model instance's reference is passed to most callbacks.)

            I'm not here much anymore.

            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