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

    Save user data on a per file basis

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 267 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.
    • liquid98L Offline
      liquid98
      last edited by

      Hi,

      I'm working on a plugin that does a scaling operation on a model.When the model is scaled up, there's a screen note (text entity) on the screen like "Scaled up 10000 times".

      Usually the user will scale down the model before saving. The screennote then disappears to indicate that the model has back its original size.

      But when the user saves the scaled up file (including the screen-note of course), the only information about the scale-up action is in that screen-note.
      How can I save that information in a more convenient way, and for several SU-files?

      Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

        Use something like
        Sketchup.active_model.set_attribute('Liquid98','scale',@sf)
        on scaling the model.
        On opening a file run
        sf=Sketchup.active_model.get_attribute('Liquid98','scale',nil)
        If 'sf' is NOT nil then you have a scaled model... and you can then 'warn' the user ?
        If the user resets the scale back to 1 you use
        Sketchup.active_model.set_attribute('Liquid98','scale',nil)
        so on rechecking later there is no warning is needed...

        TIG

        1 Reply Last reply Reply Quote 0
        • liquid98L Offline
          liquid98
          last edited by

          Thanx TIG

          OK I get the idea.. I'll experiment with that.

          Its not really about a warning, the feedback is used as a reminder of the total scale-factor. So if the model is scaled up lets say 1000 times, the user has to multiply his input accordingly. When he/she saves the model and opens it later, the script can use Sketchup.active_model.set_attribute('Liquid98','scale',@sf) to scale down the model, like you suggested.

          Another question, can you use this set_attributes method as a substitute for a global variable ( $varglobal)?

          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

          1 Reply Last reply Reply Quote 0
          • mitcorbM Offline
            mitcorb
            last edited by

            I just want to say that I am interested in the development of this idea. I wish you luck. 😄

            I take the slow, deliberate approach in my aimless wandering.

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

              @liquid98 said:

              Thanx TIG

              OK I get the idea.. I'll experiment with that.

              Its not really about a warning, the feedback is used as a reminder of the total scale-factor. So if the model is scaled up lets say 1000 times, the user has to multiply his input accordingly. When he/she saves the model and opens it later, the script can use Sketchup.active_model.set_attribute('Liquid98','scale',@sf) to scale down the model, like you suggested.

              Another question, can you use this set_attributes method as a substitute for a global variable ( $varglobal)?

              Currently you save the current [last-used] scale-factor globally into the Sketchup PC-Registry/MAC-Plist, this is then passed to a global variable [$] that used by all instances of Sketchup. As a user changes the scale-factor used the one available across SUp changes. Within each instance of SUp you are using a class variable [@0 to remember the last used setting too.
              The last used setting AND the SKP's current 'status' are different things. You may well be better to set a model-attribute to remember the scale-factor for each SKP... then you can have a script that auto-runs at startup and checks the scale-factor for the opening SKP and if it's not '1.0' then somehow warn the user by displaying the screen-text or whatever. You will need to also make an App-observer to watch for a user opening a SKP from the menu/browser within SUp etc as that way of opening a SKP would not re-run the initial file - your App-observer would do that so when you open another SKP within SUp the same check on the current SKP's scale-factor is made - see my HolePunching tool code [near to the end] for examples of making an App-observer to ensure other observers run after such opening-events - in your case the execution of some simple sf checking code will be a lot easier to do...

              TIG

              1 Reply Last reply Reply Quote 0
              • liquid98L Offline
                liquid98
                last edited by

                Thnx for the luck, mitcorb !

                Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

                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