Add folders to open dialog

Discussion in 'AutoCAD' started by T.Willey, Dec 17, 2004.

  1. T.Willey

    T.Willey Guest

    You know when you go to open, the is a list of folders on the left hand side. I had folders there once, but not anymore. I was wondering if you could place stuff there within code? I have seen routines to removes stuff, like the buzzsaw folder, and other ACAD default folders, but never saw one to add folders. I have tried on my own and failed. I don't even think I have the code that I tried around anymore, but if someone could point me in the right direction, then I can do the research.

    Thanks in advance, any help is appreciated.
    Tim
     
    T.Willey, Dec 17, 2004
    #1
  2. T.Willey

    Josh Guest

    Basically, (for each profile you have) it's a matter of three of registry
    entries for each item you want displayed. Using Jimmy Bergmark's
    http://www.jtbworld.com/download/remicons.lsp and by simply right-clicking
    in the left bar and selecting "Add current folder" I was able to figure how
    to do it....I just haven't written anything based on what learned.

    The registry entries are located at
    HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R15.0\<product-key>\Profiles\<yo
    ur profile>\Dialogs\AllAnavDialogs

    You can also do the same thing to Word but it's a bit more involved....
    http://www.jsifaq.com/SUBF/tip2500/rh2591.htm

    AND you can do the same thing to Window's Common dialog box...
    http://www.jsifaq.com/SUBF/tip2500/rh2514.htm

    One cool thing about Word is that you can make it use small icons.

    Hopefully, this is enough info for you to get started...

    Josh


    side. I had folders there once, but not anymore. I was wondering if you
    could place stuff there within code? I have seen routines to removes stuff,
    like the buzzsaw folder, and other ACAD default folders, but never saw one
    to add folders. I have tried on my own and failed. I don't even think I
    have the code that I tried around anymore, but if someone could point me in
    the right direction, then I can do the research.
     
    Josh, Dec 17, 2004
    #2
  3. T.Willey

    T.Willey Guest

    Thanks for the info. When I get a chance will drive in.

    Tim
     
    T.Willey, Dec 17, 2004
    #3
  4. T.Willey

    T.Willey Guest

    With your help Josh and a little digging I got it to work. Here is the code. The only thing is I couldn't get rid of some of the other icons, but then you can get the remicons.lsp for the link you provided to do that.

    If anyone wants to use this, just change the list of folders at the begining to the ones you want.

    Tim

    (defun c:AddFolderOpen (/ Fld2Add CurPro RegKey RegList ValList ValListDia DiaLOad
    RtnList NmOpt ProCol NewPro cnt1 cnt2 len1)
    ;|
    Adds a new profile (so you don't lose yours), based on the current one. Makes it
    current, then prompts you to select what folders you want to keep from your current
    open dialog box. Then it adds the new ones listed in the variable "Fld2Add" in order
    that you listed them, with the old ones last. Make the list in the order of
    "folder path" "name to show in dialog box" then double double quotes ("").
    By Timothy Willey Dec. 2004
    Provided as is. Tested one A2k4. Use at own risk.
    |;

    (setq Fld2Add
    (reverse
    (list
    (list "C:\\Custom\\Drawings" "Custom" "")
    (list "H:\\eMatrix\\Facilities" "Facilities" "")
    (list "C:\\ACADSUPP2004\\Template" "TitleBlocks" "")
    )
    )
    )
    (setq ProCol (vla-get-Profiles (vla-get-Preferences (vlax-get-ACAD-Object))))
    (setq CurPro (vla-get-ActiveProfile ProCol))
    (while (or (not NmOpt) (= NmOpt "N"))
    (setq NewPro (getstring T"\n Enter new profile name: "))
    (if (member NewPro (GetAllProfileNames))
    (progn
    (initget "N Y")
    (setq NmOpt (getkword (strcat "\n " NewPro " profile already exist. Save over it [<N>o Yes]: ")))
    )
    (setq NmOpt "Y")
    )
    )
    (if (/= CurPro NewPro)
    (vlax-invoke-method ProCol 'CopyProfile CurPro NewPro)
    )
    (vla-put-ActiveProfile ProCol NewPro)
    (setq RegKey
    (strcat "HKEY_CURRENT_USER\\"
    (vlax-product-key)
    "\\Profiles\\"
    NewPro
    "\\Dialogs\\AllAnavDialogs"
    )
    )
    (setq RegList (vl-sort (vl-registry-descendents RegKey "PlacesOrder") '<))
    (foreach item RegList
    (setq ValList (cons (vl-registry-read RegKey item) ValLIst))
    )
    (setq ValList (reverse ValList))
    (setq cnt1 0)
    (setq len1 (1- (length ValList)))
    (while (<= cnt1 len1)
    (if (zerop (rem cnt1 3))
    (setq ValListDia (cons (nth (1+ cnt1) ValList) ValListDia))
    )
    (setq cnt1 (1+ cnt1))
    )
    (setq ValListDia (reverse ValListDia))
    (setq DiaLoad (load_dialog "CloseDwg.dcl"))
    (if (not (new_dialog "MultiSelect" DiaLoad))
    (exit)
    )
    (mode_tile "toggle1" 1)
    (set_tile "text1" "Select folders to keep.")
    (start_list "listbox" 3)
    (mapcar 'add_list ValListDia)
    (end_list)
    (action_tile "accept"
    "(progn
    (setq RtnList (get_tile \"listbox\"))
    (done_dialog 1)
    )"
    )
    (action_tile "cancel" "(done_dialog 0)")
    (if (= (start_dialog) 1)
    (progn
    (setq RtnList (read (strcat "(" RtnList ")")))
    (foreach item RtnList
    (setq cnt1 (1+ (* 3 item))
    cnt2 (1+ cnt1)
    )
    (setq Fld2Add
    (cons
    (list
    (nth (* 3 item) ValList)
    (nth cnt1 ValList)
    (nth cnt2 ValList)
    )
    Fld2Add
    )
    )
    )
    (foreach item RegList
    (vl-registry-delete RegKey item)
    )
    (setq cnt1 0)
    (foreach item (reverse Fld2Add)
    (vl-registry-write RegKey (strcat "PlacesOrder" (itoa cnt1)) (car item))
    (vl-registry-write RegKey (strcat "PlacesOrder" (itoa cnt1) "Display") (cadr item))
    (vl-registry-write RegKey (strcat "PlacesOrder" (itoa cnt1) "Ext") (caddr item))
    (setq cnt1 (1+ cnt1))
    )
    )
    (progn
    (vla-put-ActiveProfile ProCol CurPro)
    (vlax-invoke-method ProCol 'DeleteProfile NewPro)
    )
    )
    (princ)
    )

    ;----------------------------------------

    (defun getallprofilenames (/ allprofiles)
    ;;; By Jimmy Bergmark
    ;;; Copyright (C) 1997-2003 JTB World, All Rights Reserved
    ;;; Website: www.jtbworld.com
    ;;; E-mail:
    ;;; Taken for "remicons.lsp"

    (vla-getallprofilenames
    (vla-get-profiles
    (vla-get-preferences (vlax-get-acad-object))
    )
    'allprofiles
    )
    (vlax-safearray->list allprofiles)
    )

    And the dcl I used. Save as "CloseDwg.dcl"

    MultiSelect : dialog{
    label = "Select Item";
    : list_box {
    key = "listbox";
    width = 55;
    height = 25;
    multiple_select = true;
    }
    : toggle {
    key = "toggle1";
    }
    : text {
    key = "text1";
    }
    : row {
    : spacer { width = 1; }

    : button { // defines the OK button
    label = "OK";
    is_default = true;
    allow_accept = true;
    key = "accept";
    width = 8;
    fixed_width = true;
    }

    : button { // defines the Cancel button
    label = "Cancel";
    is_cancel = true;
    key = "cancel";
    width = 8;
    fixed_width = true;
    }

    : spacer { width = 1;}
    }

    }
     
    T.Willey, Dec 21, 2004
    #4
  5. T.Willey

    Josh Guest

    Cool....glad I could help.

    Josh
     
    Josh, Dec 22, 2004
    #5
  6. T.Willey

    GaryDF Guest

    Tim

    In your routine I get an error whenever the list returned contains a nil
    (setq ValListDia (reverse ValListDia)) gives me ("History" "My Documents"
    "Favorites" "FTP" "Desktop" "Buzzsaw" nil)

    so i just used the following:
    (setq ValListDia '("History" "My Documents" "Favorites" "FTP" "Desktop"
    "Buzzsaw"l))

    ..........................
    Anyway this is what I have been using:

    Gary
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AllAnavDialogs Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;(vlax-product-key) = "Software\\Autodesk\\AutoCAD\\R16.1\\ACAD-301:409"
    ;;;(getvar "CPROFILE") = "<<Unnamed Profile>>"
    ;;;
    ;;;useage (ARCH:AddIcons "PlacesOrder0" "V:\\ARCH" "PlacesOrder0Display" "ARCH")
    ;;;
    (defun ARCH:AddIcons (podn path podp pnam / prof profiles regkey)
    (vl-load-com)
    ;;; by Jimmy Bergmark from "remicons.lsp"
    (defun getallprofilenames (/ allprofiles)
    (vla-getallprofilenames
    (vla-get-profiles
    (vla-get-preferences (vlax-get-acad-object))
    )
    'allprofiles
    )
    (vlax-safearray->list allprofiles)
    )
    (setq profiles (getallprofilenames))
    (if (not allprof) (setq profiles (list (getvar "CPROFILE"))))
    (foreach prof profiles
    (progn
    (setq regkey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)
    "\\Profiles\\" prof "\\Dialogs\\AllAnavDialogs\\"))
    (vl-registry-write regkey podn path)
    (vl-registry-write regkey podp pnam)
    )
    )
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AllAnavDialogs Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:AllAnavDialogs-Default (/ Result)
    (setq Result (ARCH:WARNING-5
    "Restore AutoCAD Default Browser Folders"
    " This Will Restore the Original Default AutoCAD\n"
    " Browser Folders.\n\n" " [ Yes ]\t to continue
    on...\n"
    " [ No ]\t Do NOT Restore." ""))
    (cond ((= Result 1)
    (princ "\n*** ///////// Program CANCELLED ///////// ***"))
    ((= Result 0)
    (ARCH:AddIcons "PlacesOrder0" "History" "PlacesOrder0Display" "History")
    (ARCH:AddIcons
    "PlacesOrder1"
    "Personal"
    "PlacesOrder1Display"
    "My Documents")
    (ARCH:AddIcons
    "PlacesOrder2"
    "Favorites"
    "PlacesOrder2Display"
    "Favorites")
    (ARCH:AddIcons "PlacesOrder3" "FTPSites" "PlacesOrder3Display" "FTP")
    (ARCH:AddIcons "PlacesOrder4" "Desktop" "PlacesOrder4Display" "Desktop")
    (ARCH:AddIcons
    "PlacesOrder5"
    "ACPROJECT"
    "PlacesOrder5Display"
    "Buzzsaw")
    (menucmd "GARCH.ID_ACAR=~")
    (menucmd "GARCH.ID_ARCH=")
    (princ "\n* AutoCAD Default Browser Folders Restored *")))
    (princ))
    ;;;
    (defun ARCH:AllAnavDialogs-Jobs (/ Result)
    (setq Result (ARCH:WARNING-5
    "Add Arch and Job Folders to Browser Folders"
    " This will add Arch Folder and Job Folders\n"
    " Job Folders Added: 2001 2002 2003 2004 2005\n\n"
    " [ Yes ]\t to continue on...\n" " [ No ]\t Do NOT Add
    Folders." ""))
    (cond ((= Result 1)
    (princ "\n*** ///////// Program CANCELLED ///////// ***"))
    ((= Result 0)
    (ARCH:AddIcons "PlacesOrder0" "V:\\Arch" "PlacesOrder0Display" "Arch")
    (ARCH:AddIcons
    "PlacesOrder1"
    "F:\\JOBS\\2001"
    "PlacesOrder1Display"
    "2001")
    (ARCH:AddIcons
    "PlacesOrder2"
    "F:\\JOBS\\2002"
    "PlacesOrder2Display"
    "2002")
    (ARCH:AddIcons
    "PlacesOrder3"
    "F:\\JOBS\\2003"
    "PlacesOrder3Display"
    "2003")
    (ARCH:AddIcons
    "PlacesOrder4"
    "F:\\JOBS\\2004"
    "PlacesOrder4Display"
    "2004")
    (ARCH:AddIcons
    "PlacesOrder5"
    "F:\\JOBS\\2005"
    "PlacesOrder5Display"
    "2005")
    (menucmd "GARCH.ID_ARCH=~")
    (menucmd "GARCH.ID_ACAR=")
    (princ "\n* Arch and Job Folders to Browser Folders Added *")))
    (princ))
    ;;;
    (defun ARCH:AllAnavDialogs-Read ()
    (cond ((= (vl-registry-read
    (strcat "HKEY_CURRENT_USER\\"
    (vlax-product-key)
    "\\Profiles\\"
    (getvar "CPROFILE")
    "\\Dialogs\\AllAnavDialogs")
    "PlacesOrder0Display")
    "Arch")
    (progn (menucmd "GARCH.ID_ARCH=~") (menucmd "GARCH.ID_ACAR=")))
    ((/= (vl-registry-read
    (strcat "HKEY_CURRENT_USER\\"
    (vlax-product-key)
    "\\Profiles\\"
    (getvar "CPROFILE")
    "\\Dialogs\\AllAnavDialogs")
    "PlacesOrder0Display")
    "Arch")
    (progn (menucmd "GARCH.ID_ARCH=") (menucmd "GARCH.ID_ACAR=~"))))
    (cond ((= (vl-registry-read
    (strcat "HKEY_CURRENT_USER\\"
    (vlax-product-key)
    "\\Profiles\\"
    (getvar "CPROFILE")
    "\\Dialogs\\AllAnavDialogs")
    "PlacesOrder5Display")
    "Buzzsaw")
    (menucmd "GARCH.ID_ACAD="))
    ((/= (vl-registry-read
    (strcat "HKEY_CURRENT_USER\\"
    (vlax-product-key)
    "\\Profiles\\"
    (getvar "CPROFILE")
    "\\Dialogs\\AllAnavDialogs")
    "PlacesOrder5Display")
    "Buzzsaw")
    (menucmd "GARCH.ID_ACAD=~")))
    ;;(menucmd "GARCH.ID_ARCH=~")
    ;;(menucmd "GARCH.ID_ACAD=~")
    ;;(menucmd "GARCH.ID_ACAR=~")
    (princ))



    The only thing is I couldn't get rid of some of the other icons, but then you can
    get the remicons.lsp for the link you provided to do that.
     
    GaryDF, Dec 23, 2004
    #6
  7. T.Willey

    GaryDF Guest

    I like it, will play around with it over the holidays.
    I would modify it to create the dcl file on the fly,
    if not found.

    ARCH#SUPF = your path

    something like:

    (defun DCL_CloseDwg (/ dcl_list dcl_write)
    (setq DCL_LIST
    (list
    "MultiSelect:dialog {label=\" Select Item\";
    :list_box {key=\"listbox\"; width=25; height=9;
    multiple_select=true;}
    :text {key=\"text1\"; width=25;}
    :row {
    :spacer {}
    :button {label=\"OK\"; is_default=true; allow_accept=true;
    key=\"accept\"; width=8; fixed_width=true;}
    :button {label=\"Cancel\"; is_cancel=true; key=\"cancel\"; width=8;
    fixed_width=true;}
    :spacer {}
    }
    }"))
    (setq DCL_WRITE (open (strcat ARCH#SUPF "CloseDwg.dcl") "w"))
    (foreach c DCL_LIST (princ c DCL_WRITE))
    (close DCL_WRITE)
    (princ)
    )

    Gary

    there was no intrest. Here is the revised routine plus a return default routine.
     
    GaryDF, Dec 23, 2004
    #7
  8. T.Willey

    T.Willey Guest

    True, but I have only a few dcl files that I use here, and I am the only cad person where I work. Change it to suit you needs. I just got tired of after something happens and I loose those folders.

    Happy Holidays.
    Tim
     
    T.Willey, Dec 23, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.