• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Java Script <> Ruby array transfer

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 1.1k Views
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 9 Mar 2008, 16:22

    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 9 Mar 2008, 16:28

      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 9 Mar 2008, 16:32

        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 9 Mar 2008, 17:47

          Yes, JSON is how you do it.

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by 14 Mar 2008, 02:35

            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
            1 / 1
            • First post
              5/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement