sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    UI openpanel - path issue?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 565 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
      tomot
      last edited by

      The sketchup-ruby-api shows Arguments: title, directory, filename
      There is no example of how to change the directory to a user path:
      Can UI openpanel be used to point to a path as below ?

      c:\Program flies (x86)\Goggle\Google SketchUp 8\Plugins\my dir

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

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

        Yes, of course.
        BUT you will need to enclose the path as a string in '', OR if you use "" you must escape every \ as \, OR you can use / instead. The \ only works on PC, but both PC and MAC use / OK.
        If you have a Plugin with a folder in the same folder - then use
        folder=File.join(File.dirname(__FILE__), 'my dir')
        and pass 'folder' to the method [for UI.openpanel as the 2nd argument]...
        It will find the path to the folder 'my dir' inside the Plugins folder automatically OR wherever the script is located.

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          If you are asking, "Can UI.openpanel return a path?"
          yes... by hotwiring it...

          baseDir = Sketchup.find_support_file('Plugins')
          relDir  = "examples"
          title   = "Choose a Dir..."
          
          openpath = File.join(baseDir,relDir)
          
          my_path = UI.openpanel( title, openpath, "*." )
          if my_path.nil?
            # the user cancelled the dialog
          else
            my_path = File.expand_path( File.dirname(my_path) )
          end
          

          (Edited for clarity, added openpath local.)

          The filetype filter does not work on PC. (Windows itself is overriding the parameters, using MRU settings in the Registry for the File Open dialog.)

          Now if you are wondering if you can first set the working dir, and will the UI.openpanel go there?
          Not really,.. you must make the call with the wd:

          Dir.chdir('C;/')
          my_path = UI.openpanel( "Choose Dir...", Dir.getwd, "*." )
          if my_path.nil?
            # the user cancelled the dialog
          else
            my_path = File.expand_path( File.dirname(my_path) )
          end
          

          I'm not here much anymore.

          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