sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Java Script <> Ruby array transfer

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 1.1k 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.
    • T Offline
      tomasz
      last edited by tomasz

      Hi all,
      I have heard it is possible to transfer JS arrays to Ruby and back.
      Could someone show me how to do it, please?

      
      <script language = "JavaScript">
      tellSketchup(list)
      
      function tellSketchup(value) {window.location='skp;ValueChanged@'+value;}
      

      'list' is an array. It is being passed to tellSketchup function.

      dlg.add_action_callback("ValueChanged") {|d,mats|;puts mats.class;dlg.close}
      

      Code above returns string.

      Tomasz

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Everything needs to passed as a string. See the link.

        Link Preview Image
        SketchUp API Blog

        Tips and Tricks for SketchUp Ruby API Developers.

        favicon

        (sketchupapi.blogspot.com)

        Hi

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomasz
          last edited by

          Thanks Jim for such a fast response! I was sure I have seen a video from SU API conference by Google and they mentioned arrays as well.. but it seems I am wrong.

          Tomasz

          EDIT:
          On the same page I have found following : πŸ˜„

          @unknownuser said:

          Looking ahead: Using JSON for more complex data....It's a way where you can pass nested objects and arrays in a single command.

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by

            Yes, JSON is how you do it.

            1 Reply Last reply Reply Quote 0
            • J Offline
              Jim
              last edited by

              I was just looking at ruby-json. I noticed there were 2 ways to use it: one c-language extension, and one called "pure". Unfortunately, the "pure" is not so pure. It requires platform specific libraries also.

              Hi

              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