CAD Forums > BricsCAD Users

Findfile + LEGACYCODESEARCH in BricsCAD

(1/1)

PrinceLISPalot:
Has anyone else noticed the change in LISP findfile behaviour in recent BricsCAD releases?

With V19 they added LEGACYCODESEARCH system variable, but it had no effect.
With V20 on, BricsCAD has LEGACYCODESEARCH, SECURELOAD, and TRUSTEDPATHS. All of which are now enabled.
It's not that well documented. Mainly discussed here
https://developer.bricsys.com/bricscad/help/en_US/V22/DevRef/index.html?page=source%2FApplicationSecurity.htm

The Lisp Developer Support Package (LDSP) includes some registry snipits in the security folder to change the behaviour back to legacy. This requires Admin access, as these are under the HKEY_LOCAL_MACHINE
https://boa.bricsys.com/applications/a/?lisp-developer-support-package-(ldsp)-a720-al1176

If you're a CAD admin and you want to set TRUSTEDPATHS, then you would need to edit the registry key. As far as I'm aware there is no interface provided to set.

I find the LISP findfile behaviour annoying as it now fails to find files in the current drawing folder. I know they have simply implemented the same functionality as AutoCAD, but I don't get the logic of having a function to find files that doesn't always find files!

I commonly store files in the same folder as the current drawing. These aren't LISP, often just simple text files.

LEGACYCODESEARCH is not offering any protection, as it you can simply build a new search function to get around the limitation. here are a couple of examples that follow legacy behaviour to findfiles.


--- Code - Auto/Visual Lisp: ---;LEGACYFINDFILE ; Provides legacy findfile behaviour without the need of setting LEGACYCODESEARCH = 1; Searches in the following order:; - If a folder path is included with the filename, searches just there.; - Current drawing folder.; - Start-In folder. This is the folder that the progam has been launched from; - Installation folder. Folder that application has been installed in.; - Folders listed on search path, normal findfile behaviour  (defun legacyfindfile (fn / startin dwgfolder installkey installfolder return)        (setq startin (strcat (vl-string-right-trim "\\." (findfile ".")) "\\")) ; Finds the Start-In folder. BricsCAD returns the "\\." AutoCAD doesn't        (setq dwgfolder (getvar 'DWGPREFIX)) ; current drawing folder        ; Retrieve the Installation folder from registry. BricsCAD returns the "\\" AutoCAD doesn't        (setq installkey (if (= (getvar 'PROGRAM) "BRICSCAD") "InstallDir" "acadlocation")) ; reg key is application specific        (setq installfolder (strcat (vl-string-right-trim "\\" (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-product-key)) installkey)) "\\"))        (cond      ; GIVEN FOLDER      ; If the filename includes the path or starts with "."      ((or (/= (vl-filename-directory fn) "") (= (substr fn 1 1) "."))                                 (setq return (findfile fn))                        )                        ; CURRENT DRAWING FOLDER                        ; If the drawing has been saved, then search the current dwgfolder for the file                        ((and (= (getvar 'dwgtitled) 1) (setq return (findfile (strcat dwgfolder fn))))                         return                        )                        ; START-IN FOLDER                        ; Search the start-in folder for the file.                        ; This step may not be necessary as normal findfile searches here in anycase.                        ; However, this does insure that it follows legacy search order                        ((setq return (findfile (strcat startin fn)))                         return                        )                        ; INSTALL FOLDER                        ; Search the installation folder for the cad application                        ; again not necessary as normal findile searches here too                        ((setq return (findfile (strcat installfolder fn)))                         return                        )      ; SEARCH PATH      ; Use standard findfile behavior to search the support file search path                        (T (setq return (findfile fn)))        )return)


--- Code - Auto/Visual Lisp: ---; BCADLEGACYFINDFILE; Does the same based on a specific list of folders.; Requires BricsCAD VLE Extension for it to work in AutoCAD (defun bcadlegacyfindfile (fn / searchfolders installkey flag return)  (cond    ; GIVEN FOLDER    ; If the filename includes the path, or starts with "."     ((or (/= (vl-filename-directory fn) "") (= (substr fn 1 1) "."))          (setq return (findfile fn))     )     ; SEARCH FOLDERS     ; Search for the file across our list of searchfolders    (T      ; Build search folder list      ; Current drawing       (if (= (getvar 'dwgtitled) 1) (setq searchfolders (getvar 'DWGPREFIX)))       ; Start-in        (setq searchfolders (strcat searchfolders ";" (findfile ".")))  ; Finds the Start-In folder.       ; Installation folder.       (setq installkey (if (= (getvar 'PROGRAM) "BRICSCAD") "InstallDir" "acadlocation"))  ; reg key is application specific       (setq searchfolders (strcat searchfolders ";" (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-product-key)) installkey)))       ;Support file search path       (setq searchfolders (strcat searchfolders ";" (getenv "ACAD")))       ;convert to list and clean up path end       (setq searchfolders (mapcar '(lambda (fol) (strcat (vl-string-right-trim "\\." fol) "\\")) (vle-string-split ";" searchfolders)))       (setq flag T)        (while (and flag searchfolders)          (cond            ((setq return (findfile (strcat (car searchfolders) fn)))                   (setq flag nil)            )            (T (setq searchfolders (cdr searchfolders) flag T))          )        )    )  )  return)

Navigation

[0] Message Index

Go to full version