sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Tutorial] Beginning Ruby 2 - Writing a Script

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 327 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      All right, I finally put together a second tutorial on script writing in Ruby. It is located here (the advanced tutorial section of the main sketchucation site):

      Link Preview Image
      SketchUcation

      3D SketchUp Community for Design and Engineering Professionals.

      favicon

      (www.sketchucation.com)

      The first one is here.

      Anyhow, look it over. Its a pretty baic script that iterates through a model, finds all the faces, then pushpulls them to a specified distance. It shows how to use the undo stack, safety wrap a scipt inside a module, use the inputbox, and add the script to the menu system.

      One of the coolest things about the tutorial is Coen's new Ruby feature in the tutorials section. So instead of screenshots of ruby, it actually has ruby code that you can copy and paste.

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • CadFatherC Offline
        CadFather
        last edited by

        Thanks Chris, this is great - who knows one day even i.. πŸ˜„

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

          Nice one Chris.

          I'd like to point out some inconsistency though.

          Some places you use .typename and some places you use .is_a?.

          Interesting findings from this post, http://forums.sketchucation.com/viewtopic.php?f=180&t=19576&start=0#p162235 , shows that .typename is very slow. Best practice would be to use .is_a? or .kind_of? (they are aliases of the same method.) Or compare the .class .

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

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            Oops, I should fix that. Its a remnant of the old script where I used .typename regularly. I guess I forgot to update it in some places. I know the first tutorial still uses .typename because I did not get a chance to update that one. I'm planning on redoing the entire tutorial.

            So I'll look them both over for inconstiencies again. I also want to add more links back to the API in the 2nd one. There are a few methods I refer to but don't link back to them.

            Thanks Thom!

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

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

              I wonder if we should make a sticky thread that list some of these 'tricks' / 'best practices' that's scattered throughout the forum... ?

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

              1 Reply Last reply Reply Quote 0
              • 3 Offline
                3eighty
                last edited by

                Are the rubie scripts based in the old dBase manner. It's been years for me but it looks almost the same as I remember...

                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