sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    UI.openURL(executable + params)

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 6 Posters 3.7k Views 6 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

      Hi All,

      I wonder if there is way to pass parameters to an executable directly through
      UI.openURL("C:\format.exe /Y c:") 😆 ? The example unfortunately doesn't work although I have copied format.exe to root directory 😄 8O I use DOS batch file but it is not compatible with MAC.

      Related question to MAC users. What extension have executables on MAC and how should look proper UI.openURL(.....) for MAC?

      Cheers
      Tomasz

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

      1 Reply Last reply Reply Quote 0
      • R Offline
        RickW
        last edited by

        It appears that because UI.openURL is designed to open an internet address, it doesn't accept parameters (which don't exist in internet addresses).

        RickW
        [www.smustard.com](http://www.smustard.com)

        1 Reply Last reply Reply Quote 0
        • A Offline
          azuby
          last edited by

          Use the "system" call or backticks for this purpose, i.e.:

          s = system "dir" # -> true
          s = `dir` # -> a lot of stuff ;)
          

          Don't use "exec"!

          Executables on Mac do not have a special extension, because file extensions are not relevant for the OS in most cases. Executables are marked as executable in the file system. You can make Ruby scripts executable, i.e. by calling "chmod +x" AND writing down a Shebang line on top of the .rb file.

          azuby

          *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

          Bad English? PM me, correct me. :smile:**

          1 Reply Last reply Reply Quote 0
          • Didier BurD Offline
            Didier Bur
            last edited by

            I don't agree with Rick, openurl is not restricted to internet links.
            One can write: UI.openURL("file://" + the_file_to_open)
            The system then uses the registry to launch the correct app.
            You can also write UI.openURL("c:\test.exe"), this will launch the programm "test"
            I guess you could do it also on Mac, but there are no registry and extensions on it...
            I don't know if you can add parameters to the command 😳
            Regards,

            DB

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

              Thanks Lads,

              Azuby has killed me, I hope I will recover soon 😄.
              I need to run Kerkythea.exe (on Mac kerkythea) with single parameter (KT script file name).
              On PC I create separate start.bat file containing :
              kerkyhea.exe start.kst

              Then I run this batch using UI.openURL(C:\start.bat) which opens command line window, starts batch file and finally opens KT. 'Dos' window is visible in the background so it is not clean solution.

              Azuby - how it will look using your backtick? 😆

              Tomasz

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

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by

                @didier bur said:

                I don't agree with Rick, openurl is not restricted to internet links.
                One can write: UI.openURL("file://" + the_file_to_open)
                The system then uses the registry to launch the correct app.
                You can also write UI.openURL("c:\test.exe"), this will launch the programm "test"
                I guess you could do it also on Mac, but there are no registry and extensions on it...
                I don't know if you can add parameters to the command 😳
                Regards,

                I didn't say you couldn't open an app, I said you couldn't use parameters. 😄
                Just because something can be done doesn't mean it was intended. So, because the method accepts an URL (even a local one), and because URLs don't have parameters, then it won't work for what is being attempted (even though opening an app without using parameters will work).

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • A Offline
                  azuby
                  last edited by

                  @unknownuser said:

                  Azuby - how it will look using your backtick? 😆

                  Germans are not funny 😛 , so I don't know, whether this is just fun question. Backticks are one of these little diacritic marks i.e. French use on "a", "e" and so on: "à", "è" ... Look my code above, I wrote **dir**. Between the backticks you write the call as you would write it in batch file or command line; for a coloured directory listing on Mac you could write ls -Glas or ls -G -l -a -s. If you do not need the result of the call, just information whether it failed or not, use the "system" call, if you want to get the result, than use backticks. And if you want to kill Sketchup, use "exec" 😉

                  azuby

                  *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                  Bad English? PM me, correct me. :smile:**

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

                    @unknownuser said:

                    'Dos' window is visible in the background so it is not clean solution.

                    I think if you use the command "start" before the name of the executable, the dos window will disappear after executing the batch file.

                    start kerkythea.exe script.kst

                    Whaat

                    SketchUp Plugins for Professionals

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

                      Thanks Azuby,
                      Don't worry. I am not familiar with MACs at all. You are simply at the much higher level of programming then me, so most of what you are writing sounds like a Chinese to me 😄 I simply would like to start Kerkythea on MAC with start.kst file as a parameter (file to be opened when KT starts).
                      By the way, next version of KT is expected in few months and it will be available for MAC!
                      It is what Giannis says.

                      Thanks Whaat,
                      I have done some investigation and the line in the batch file should look like:
                      start "" "C:\Program Files\Kerkythea\Kerkythea.exe" "start.kst"
                      Now it works (PC only 😞 )!

                      Tomasz

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

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

                        Azuby, I have finally understood what you have written in you first post (I am not very familiar with standard Ruby methods). It works excellent with "dir", but for some reason KT is being opened only when I close SU otherwise SU is hanging and KT awaiting to start (edit - it takes about 40sec KT to start).

                        system("Kerkythea.exe start.kst")
                        
                        s=`Kerkythea.exe start.kst`
                        

                        works fine. Is it possible to run KT as a separate thread,
                        so SU would be still working?

                        Tomasz

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

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

                          s=`c;/Program Files/Kerkythea/Kerkythea.exe "c;\\Program Files\\Kerkythea\\start.kst"`
                          

                          It is script that will run exe with parameter in "" (PC).
                          For MAC I presume I will have to replace all \ by /.

                          Still don't know how to keep SU alive when KT is running.

                          Tomasz

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

                          1 Reply Last reply Reply Quote 0
                          • A Offline
                            azuby
                            last edited by

                            Moin,

                            you can't do this with Ruby threads, they let Sketchup freeze while your other application is running. The code would be

                            Thread.new do `WHATEVER` end
                            

                            Also you can't use exec or fork. The only way would be writing a really simple server application, running it on localhost and call it from Sketchup.

                            azuby

                            *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

                            Bad English? PM me, correct me. :smile:**

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

                              Any ideas what's causing this glitch ?

                              help=Sketchup.find_support_file("RoofHelp.mht","Plugins/")
                              #=big file, but works...

                              help=Sketchup.find_support_file("RoofHelp.pdf","Plugins/")
                              #=small file, but not working ???

                              UI.messagebox("ERROR\nRoof Help File NOT found.") if not UI.openURL("file:///"+help)

                              On a PC with Vista UI.openURL will open almost any type of file except a PDF ?

                              This is delaying my beta issue of Roof.rb as it needs a help file !

                              TIG

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

                                The file name is case sensitive. Does it matter?
                                Try dir with the folder and look for the file.upcase.
                                Tomasz

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

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

                                  I don't think it's the case or another thought I had was even blank-spaces in paths (tried gsub 20% etc without any change in results).

                                  It just seems to dislike PDF files - other types - mht, htm, doc, txt et al work OK...

                                  Is it a setting in Vista ?

                                  TIG

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

                                    I have no idea. I am working on XP.

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

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

                                      @unknownuser said:

                                      I have no idea. I am working on XP.

                                      Thanks anyway.

                                      Just upgraded to a new PC - Core 2 Quad with 2Gb RAM - but it runs Vista...

                                      Vista seems to be the problem...

                                      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