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

    How to launch applications on Mac with Ruby?

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 4 Posters 562 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.
    • W Offline
      Whaat
      last edited by

      Hi,

      On PC, I am using UI.openURL(file_path) to open an application or run a batch file. This does not seem to work on Mac. Or does it? How do you launch an application on a Mac with Ruby?

      Also, can you create and run a batch file on a Mac? Does Mac have something equivalent to batch files?

      Thanks!

      SketchUp Plugins for Professionals

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

        Hi Whaat,
        There was a thread dedicated to this issue.

        In SU2KT I do it this way:

        @unknownuser said:

        Thread.new do
        system(command options)
        end

        I though it will allow KT to run without freezing the SU, but it works only for very limited time.

        I hope we can find proper way to do it on both systems.

        Tomasz

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

        1 Reply Last reply Reply Quote 0
        • AdamBA Offline
          AdamB
          last edited by

          Ha. I find totally the opposite so in LightUp I have to do:

          UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
          
          

          On (my test) PC, it just crashes.

          Un*x systems have very flexible 'batch files'. They can be arbitrary languages too but adding a line at the beginning of the batch file. Starting with:

          #!/bin/bash
          
          

          means run this batch file using this flavor of shell (aka Cmd.exe in Win32)

          Developer of LightUp Click for website

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by

            @adamb said:

            Ha. I find totally the opposite so in LightUp I have to do:

            UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
            > 
            

            So this works to open an App or file on a Mac? (I can't test right now)

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • W Offline
              Whaat
              last edited by

              @unknownuser said:

              Hi Whaat,
              There was a thread dedicated to this issue.

              In SU2KT I do it this way:

              @unknownuser said:

              Thread.new do
                system(`command options`)
              end
              

              I though it will allow KT to run without freezing the SU, but it works only for very limited time.

              I hope we can find proper way to do it on both systems.

              Tomasz

              Thank Tomasz, I am aware of the thread but I did not see a solution that worked with Mac. I am able to launch Indigo with parameters using a batch file on a PC (the command window closes after execution) but I am trying to figure out how to do the equivalent on a Mac

              SketchUp Plugins for Professionals

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

                @whaat said:

                [I am aware of the thread but I did not see a solution that worked with Mac.

                I thought that

                system(`command options`)
                

                works fine on Mac. At least I have had such an impression from posts from Mac users on KT forum.
                Unfortunately I have no Mac available to test it on my own.
                The method will probably block SU on MAC, so it is not a perfect solution anyway.

                Tomasz

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

                1 Reply Last reply Reply Quote 0
                • AdamBA Offline
                  AdamB
                  last edited by

                  @whaat said:

                  @adamb said:

                  Ha. I find totally the opposite so in LightUp I have to do:

                  UI.openURL("file;//" + File.expand_path(filepath)) if filepath and not(PLATFORM.include? "mswin")
                  > > 
                  

                  So this works to open an App or file on a Mac? (I can't test right now)

                  OK, it looks like PC just can't handle being given a scheme handler. If you just give the path on PC it works fine. On the Mac, it (correctly in my book) expects a scheme handler for the URL.

                  Adam

                  Developer of LightUp Click for website

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    UI.openURL("file;//" + File.expand_path(filepath))
                    

                    works fine on a PC, if 'filepath' points to either an exe-file ora file-type... I don't see the issue ?
                    If you want to open a file with a particular app on a PC use a WinScript socket...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • AdamBA Offline
                      AdamB
                      last edited by

                      Not on my WinXP laptop. Just crashes.

                      Developer of LightUp Click for website

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        Works fine on my PC with Vista. Opens an app (.exe) or a file with it's assigned app...
                        Puzzling...

                        TIG

                        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