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!
    FredoBend | Powerful new bending tool for SketchUp Download

    UI openpanel - path issue?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 623 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
      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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better đź’—

          Register Login
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement