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

    Ruby system call

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 687 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
      spring.freediver
      last edited by

      Does the system function work in SketchUp Ruby?

      Any tips on how to use it?

      I am passing in two args, the full path to a .exe file (cmd), and the full path to a file I want the executable to process (file). I get nothing.

      I also tried (UI.messagebox cmd file, using the backtick syntax, but it interpreted the arguments literally, saying:

      Error: #<Errno::ENOENT: No such file or directory - cmd file>

      Do I need to use some special quoting technique?

      Thanks,
      Jeff

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

        What's the full path to the file you try to execute? Does it contain non-ASCII characters by any chance?

        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

          I'm not sure about your system call question. But if you want to display the cmd file variables correctly inside the messagebox, try it without the quotes and it will evaluate the variables, instead of printing the variable name

          UI.messagebox cmd + file

          or, if you wanted to display them inside a string, do it like this:

          UI.messagebox "I am trying to run this file: #{cmd+file} and I hope it works eventually!"

          the #{ } syntax will evaluate whatever is inside the braces when they inside a string (must use double quotes " instead of single quotes ' around the string from what I understand. You can even call a method and run regular code inside the braces, like this:

          ` def my_method
          cmd = "the path"
          file = "filename"
          cmd+path
          end

          UI.messagebox "This is the path #{my_method}."`

          And that should work too.

          But it doesn't answer the question that you had I think.....sorry.

          Chris

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

          1 Reply Last reply Reply Quote 0
          • S Offline
            spring.freediver
            last edited by

            Tom,

            To set the command path, I use the $: system variable to get a path to the Plugins directory, and then tack on the rest of the path to the executable. No special characters. Before doing the system call, I print out both the cmd and file strings, and they look correct.

            Jim,

            The backquotes I am using are supposed to run the command in the quotes, and return the command output as a string. I wanted that returned string to go to a messagebox, which it did... the error message I showed in my original post.

            Thanks for the help.
            Any more suggestions?

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

              #{cmd} #{file}`` ?

              Hi

              1 Reply Last reply Reply Quote 0
              • S Offline
                spring.freediver
                last edited by

                Yes, that works. Thanks Jim.

                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