sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Set/Get Attribute

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 251 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.
    • A Offline
      Anton_S
      last edited by

      Attributes acts like a file for each model.

      When we call eval(some attribute), it is similar to task load(file).
      Am I thinking right?

      **If do then:**I was disturbed or in better words got stuck by the idea of how scripts are writen in sketchy physics. The thing that disturbed me was the miss-use of variables:

      ` onstart{
      @things = []
      @count = 0
      @hello = 10

      def getEntByName(name)
      ...
      end
      }`

      Creating instance varibales outside of class doesn't report errors, but they just act like global variables. For instance: I assign instance varible @count = 10, outside of class, in some attribure and eval the attribute. Then I set_attribute @count for another model and eval it too. The evaluation of second attribute would return me "10", but not the error that I expected. I don't understand how attributes work. If I eval it, does it even becomes defined in the plugin files? I need some explanation on that, I'm stuck.

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

        You are confusing RUBY attributes (aka instance variables,) with SKP dictionary attributes (aka data fields.)

        They are not the same thing, although both can be called attributes.

        I'm not here much anymore.

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

          So, its the right way to use @ kind of variables in Attribute Dictionary?

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

            @anton_s said:

            So, its the right way to use @ kind of variables in Attribute Dictionary?

            They are not related in any way. Maybe it would be best if you described what you are trying to achieve?

            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
              Anton_S
              last edited by

              @thomthom said:

              @anton_s said:

              So, its the right way to use @ kind of variables in Attribute Dictionary?

              They are not related in any way. Maybe it would be best if you described what you are trying to achieve?

              It's the scripts that confuse me in sketchy physics 'onTick' or 'scripted' fields.
              Examining someones script, like Mr.k's or Wacov's, I usualy find instance variables that are not assigned and used in the class, but are writen outside of class, like local or global variables. The example is in my first post. I want to know if it is the right way to write scripts like they did, using instance variables as the variables.

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

                Not in the global Objectspace, no...

                ... all your code should be inside your unique toplevel module, and all your classes should be inside that as well.

                I'm not here much anymore.

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

                  @dan rathbun said:

                  Not in the global Objectspace, no...

                  ... all your code should be inside your unique toplevel module, and all your classes should be inside that as well.

                  Okay, that's what I thought. It was just the wrong use of variables, and people who were learning ruby from sketchy physcics scripts did the same thing, so now I know, Thanks ๐Ÿ˜„

                  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