Videos

Programmatically Set the Select File Saved Places Locations

Issue:

You would like to automatically set the Places locations on your Select File (open command) dialog for AutoCAD and vertical products.

Solution:

The Places locations are stored within the AutoCAD profile of the Current users’s registry at the path below.

HKEY_CURRENT_USERSoftwareAutodeskAutoCADRXX.XXACAD-XXXX:XXXProfiles<<PROFILE NAME>>DialogsAllAnavDialogs

To set these, you can manually edit their locations and positions from within AutoCAD, then browse to the registry and export that entry to share with others, OR more simply use the following lisp routine to execute the locations to be set via what you program at the end of the code.

<code>

;;Written by Steve Hill, Red Transit Consultants, LLC
;;February 5, 2019
;;Version 1.0

;;======================================================================================================================
;;====================DO NOT MODIFY THIS SECTION OF CODE================================================================
;;======================================================================================================================
(vl-load-com)

(defun getActiveProfile ()
    ;; This example returns the current setting of
    ;; ActiveProfile.
    (setq acadObj (vlax-get-acad-object))
    (setq preferences (vla-get-Preferences acadObj))
    
    ;; Retrieve the current ActiveProfile value
    (setq currActiveProfile (vla-get-ActiveProfile (vla-get-Profiles preferences)))
);defun

(defun strToList ( strg strDelimiter / strgLen newLst curPos )
    (setq strgLen (1+ (strlen strDelimiter)))
    (while (setq curPos (vl-string-search strDelimiter strg))
        (setq newLst (cons (substr strg 1 curPos) newLst) strg (substr strg (+ curPos strgLen)))
    );while
    (reverse (cons strg newLst))
);defun

(defun createLastRegEntry (number)
    (if (vl-registry-write regPath)
        (progn
            (vl-registry-write regPath (strcat “PlacesOrder” (itoa number)) “”)
        );progn
    );if
);defun

(defun createRegistryEntry (number plcName plcPath)
    (setq verNum (nth 3 (strToList (vlax-product-key) “\”)))
    (setq verPro (nth 4 (strToList (vlax-product-key) “\”)))
    (setq regPath (strcat “HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\” verNum “\” verPro “\Profiles\” (getActiveProfile) “\Dialogs\AllAnavDialogs”))
    
    (if (vl-registry-write regPath)
        (progn
            (vl-registry-write regPath (strcat “PlacesOrder” (itoa number)) plcPath)
            (vl-registry-write regPath (strcat “PlacesOrder” (itoa number) “Display”) plcName)
            (vl-registry-write regPath (strcat “PlacesOrder” (itoa number) “Ext”) “”)
        );progn
    );if
);defun

INTERESTING:   AutoCAD -- Maximize Viewports, Minimize Effort (Lynn Allen/Cadalyst)

;;======================================================================================================================
;;====================DO NOT MODIFY THIS SECTION OF CODE================================================================
;;======================================================================================================================

;;======================================================================================================================
;;====================EDIT THE ENTRIES BELOW============================================================================
;;======================================================================================================================
;;Each registry entry is done with the function ‘createRegistryEntry’
;;Provide an entry number, Name, and path
;;Be sure to use “\” in your paths
;;Be sure you incrementally increase your entries (ie: 0, 1, 2…)
;;Be sure to end the code with the function ‘createLastRegEntry’ and increment that number as well
;;There is no command to execute, just load up the lisp routine and it executes.
(createRegistryEntry 0 “History” “History”)
(createRegistryEntry 1 “Documents” “Personal”)
(createRegistryEntry 2 “Favorites” “Favorites”)
(createRegistryEntry 3 “Desktop” “Desktop”)
(createRegistryEntry 4 “FTPSites” “FTP”)
(createRegistryEntry 5 “TEST” “C:\temp”)
(createLastRegEntry 6)

</code>

 

 Warning! 
Problems caused by improperly editing the Windows registry could render your computer operating system unusable. Microsoft provides a wealth of critical information that you need to know about the registry in the Microsoft Knowledgebase. Use the Microsoft Registry Editor only at your own risk and only after backing up the registry as outlined for your operating system in the Microsoft article How to back up and restore the registry in Windows and in the related solution How to back up the system registry. Additional information about the registry is also contained in the Help topics in the Microsoft Registry Editor.

    Attachments

  • SetSelectFilesPlacesLocations.lsp(0 MB)

Source: Autodesk

Back to top button

Adblock Detected

Please disable your ad blocker to be able to view the page content. For an independent site with free content, it's literally a matter of life and death to have ads. Thank you for your understanding! Thanks