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

    Saving all instance variables of an object

    Scheduled Pinned Locked Moved Developers' Forum
    14 Posts 4 Posters 1.1k 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.
    • S Offline
      slbaumgartner
      last edited by

      @abakobo said:

      Why must I use @ or $ for my obj2?
      [

      These prefixes are part of the names of variables. They tell Ruby what scope the variables belong to (@ for attributes of objects, $ for globals - there is also @@ for class variables). Variables without one of these leading characters are local to the code scope where they appear.

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

        @slbaumgartner said:

        They tell Ruby what scope the variables belong to (@ for attributes of objects, $ for globals

        And for the record - global variables should be avoided. In Extension Warehouse they are an immediate rejection.

        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

          @thomthom said:

          And for the record - global variables should be avoided. In Extension Warehouse they are an immediate rejection.

          And yet.. the global objectspace is still cluttered with global variables created by SketchUp Team extensions!

          Many of these are for LanguageHandler instances that are no longer needed once the Preferences UI strings have been loaded, or a local extension hash loaded with strings.

          I'm not here much anymore.

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

            Yea - there's a need for a cleanup for the old SketchUp extensions.

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

            1 Reply Last reply Reply Quote 0
            • A Offline
              abakobo
              last edited by

              I tried to save an object containing an SKUI window object (using marshal) and had a bad type error... I suppose it's not possible to save an SKUI window with marshal due to it's limitations:

              *Marshal can't dump following objects:

              anonymous Class/Module.
              
              objects which related to its system (ex: Dir, File::Stat, IO, File, Socket and so on)
              
              an instance of MatchData, Data, Method, UnboundMethod, Proc, Thread, ThreadGroup, Continuation
              
              objects which defines singleton methods*
              

              I did it manualy this time but wonder if there's something similar to Marshal with what I would be able to save objects containing SKUI windows for later use.

              I remeber i saw somthing with a name looking like "yalm"..
              Would Pstore do it?

              Many Thanks

              ako

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

                Classes needs to implement support for marshalling. In the case of SKUI the Window class holds on to references to UI::WebDialog - which cannot be serialized. This also is also the case for Sketchup::Entity derived classes.

                Btw, why are you trying to marshall a SKUI Window? Are you trying to save the window position?
                Or are you trying to save the whole state of it - including HTML content and session?

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

                1 Reply Last reply Reply Quote 0
                • A Offline
                  abakobo
                  last edited by

                  I'm trying to save all the .visible? .caption(for lbls) and .value(for inputs) for now.

                  I would like to create a window where there's a "add item" on the window that add a SKUI_group on the window corresponding to the new item...
                  My object have only two instance variables for now, the number of items(an int) and the SKUI window.

                  For the non customisable plugin I could save the .visible? .caption and .value by listing them manualy in my Save method but with a customizable window it would probably be painful...

                  thanks for your answers
                  AND THANKS A LOT FOR SKUI (sorry for shouting but i really mean it)

                  P.S. I noticed a little bug: I have to initialise myself the .visible of each visible unmodified SKUI items before saving them because it was returning nil with the .visible? method if .visible= was never used.

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

                    @abakobo said:

                    P.S. I noticed a little bug: I have to initialise myself the .visible of each visible unmodified SKUI items before saving them because it was returning nil with the .visible? method if .visible= was never used.

                    Hmm... Could you file this bug in the GitHub repo with a small code snippet?

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

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      abakobo
                      last edited by

                      I never did that but will learn how to.
                      Glad to participate... 😄

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        abakobo
                        last edited by

                        Bug posted in the GitHub Issues field!

                        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