• Login
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 18 Sept 2011, 21:36

    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
    • T Offline
      TIG Moderator
      last edited by 18 Sept 2011, 22:06

      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
      • D Offline
        Dan Rathbun
        last edited by 18 Sept 2011, 22:36

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

        Advertisement