+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
  1. #1
    Junior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2012
    Posts
    17

    Default Macro to Open File Dialog Box to a Specific Location

    Registered forum members do not see this ad.

    I have created a new menu item which will allow a user to bring up the Open File Dialog window. But I need to request that it open up to a specific default location each time it's run rather than the last opened folder.

    Right now the macro for this new command is ^C^C_open.

    Is there a method which will allow us to specify the folder location to open?

  2. #2
    Junior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2012
    Posts
    17

    Default

    I was pointed in the right direction by another co-worker on this. She suggested

    Code:
    ^C^C^P(startapp "explorer.exe T:")
    and she was right. It worked fine. Still I was hoping to get the real "Open" window in autocad, not just the generic explorer window.

  3. #3
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,090

    Default

    Thank you for sharing that solution with us Brenda. Now if everyone who came here could be as efficient as you (ask and answer your own question) we could all take the day off and go to the beach and enjoy a frosty cold beer too. LoL
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    So, you were looking to access a network drive mapped as T:? This is equivalent with:
    Code:
    ^C^C^C(startapp "explorer.exe” “T:\\") ^P
    Your first post let me the impression that you were looking to have the drawing selection dialog of OPEN command pointing to a predefined path, rather than default, current folder.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Junior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2012
    Posts
    17

    Default

    Thanks again to all of you. I would prefer to have the OPEN command pointing to a pre-defined path. This macro uses Windows Explorer, which is ok, but it doesn't bring up the typical File Open window in Autocad, instead it brings up an instance of Windows Explorer. Which if it works is ok.

    I am still having some troubles with this macro, for instance this morning I can type this at the command line:

    Code:
    (startapp "explorer.exe" "T:\\Checker")
    and it opens up Windows Explorer at this folder location on the T: drive. But I copy and paste the same thing in the CUI for this particular menu command and nothing happens.

    Code:
    ^C^C(startapp "explorer.exe" "T:/Checker")
    This macro, however, works just fine from the menu item or from the command line.

    Code:
    ^C^C^P(startapp "explorer.exe "T:")

  6. #6
    Junior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2012
    Posts
    17

    Default Still Not Working

    MSasu,

    Thanks again for your replies, but I tried the syntax you offered and all it did was dump the contents of that syntax on the command line. What's so difficult about this is that I can do this on the command line:

    Code:
    (startapp "explorer.exe" "T:\\Checker")
    and it works fine. Yet the macro in the CUI for this menu item like this:

    Code:
    ^C^C^P(startapp "explorer.exe" "T:\\Checker")
    produces nothing...no message or error indications at all and mostly no Windows Explorer opened up to the T:\Checker folder. I'm really perplexed on this one.

  7. #7
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    When create the macro for toolbar button, you should pay attention to end it with a space character - it act like an <Enter> to run the statement.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  8. #8
    Junior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2012
    Posts
    17

    Default

    Yes, that you are correct on...and I should say that I've been cognizant of that. I have tried it using a space, a semi-colon, two semi-colons...etc. Just about anything to get it to work. What I can also say is that if I leave off the folder name and just use the drive name "T:" it works fine from the cui menu macro. I can make this work also from the command line in addition to adding the folder name. It all seems to work well from the command line but not when it's inserted as the syntax for the menu macro. I don't get it.

  9. #9
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,000

    Default

    Brenda, if no one offers to test this until tomorrow, I will do some tests for you in AutoCAD's menu (don't have access to it right now).
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  10. #10
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Brenda Tanner View Post
    I would prefer to have the OPEN command pointing to a pre-defined path. This macro uses Windows Explorer, which is ok, but it doesn't bring up the typical File Open window in Autocad, instead it brings up an instance of Windows Explorer.
    There are multiple ways to accomplish this, using GETFILED function for example, but just for fun:

    Here's a sample Macro for a predefined location:

    ** Note - The use of a single forward-slash "/" in the macro, as double back-slash "\\" will result in a PAUSE for user input.

    Code:
    ^C^C^P(_OpenHere "T:/Checker");._open;^P
    ... And the supporting "_OpenHere" LISP sub-function:

    This sub-function accepts a single argument, a file path as String, and verifies that the file path is a valid location prior to updating the aptly named "InitialDirectory" registry key which defines the starting point for the OPEN dialog. This code also accounts for both pre, and post 2013 LISP functions for product key.

    Code:
    (vl-load-com)
    
    (defun _OpenHere (filePath / key)
    
      (if vlax-user-product-key                                             ; If using 2013
        (setq key (vlax-user-product-key))                                  ; Then, use new lisp function
        (setq key (vlax-product-key))                                       ; Else, use legacy function
      )
      ;; More info here:
      ;; http://www.cadtutor.net/forum/showthread.php?70845-AutoLISP-API-Changes-for-AutoCAD-2013-Updated
    
      (if (setq
            filePath (vl-string-translate
                       "\\"
                       "/"
                       (findfile (vl-string-right-trim
                                   "/"
                                   (vl-string-right-trim "\\" filePath)
                                 )
                       )
                     )
          )
        (vl-registry-write
          (strcat
            "HKEY_CURRENT_USER\\"
            key
            "\\Profiles\\"
            (vla-get-activeprofile
              (vla-get-profiles
                (vla-get-preferences (vlax-get-acad-object))
              )
            )
            "\\Dialogs\\OpenSaveAnavDialogs"
          )
          "InitialDirectory"
          filePath
        )
      )
      (princ)
    )
    HTH
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. File open Dialog box
    By Majicdobe in forum AutoCAD Beginners' Area
    Replies: 15
    Last Post: 19th May 2012, 04:02 pm
  2. macro to open from specific template
    By designerstuart in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 14
    Last Post: 17th Oct 2011, 03:28 pm
  3. VBA - Open File Dialog
    By Hickoz_bro in forum .NET, ObjectARX & VBA
    Replies: 4
    Last Post: 12th Jul 2011, 12:06 pm
  4. File, Open - Dialog Box
    By cninneman in forum AutoCAD Drawing Management & Output
    Replies: 9
    Last Post: 19th Feb 2011, 03:56 am
  5. File Open dialog box not displaying
    By xhemil.k in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 20th Mar 2009, 11:25 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts