Loading lisp files on startup from SharePoint
At our office we work with different people with the same menu structure in bricscad. Various lsp files are subsequently loaded that are stored on a SharePoint site. This data is synchronized via Onedrive. The path to these files is different for everyone. I have tried below code in on_doc_load.lsp file
(defun load-lsp ()
(foreach file (vl-directory-files "C:\\Users\\" (getenv "username") "\\J.A. van Gisbergen B.V\\WVB overleg - Documenten\\Bricscad\\Support" "*.lsp" 1)
(load (strcat "C:\\Users\\" (getenv "username") "\\J.A. van Gisbergen B.V\\WVB overleg - Documenten\\Bricscad\\Support\\" file))
)
)
(load-lsp)
But this has the following error:
_QNEW
; ----- LISP : Call Stack -----
; [0]...LOAD-LSP <<--
;
; ----- Error around expression -----
; (GETENV "username")
; in file :
; C:\Program Files\Bricsys\BricsCAD V24 en_US\Support\on_doc_load.lsp
;
; error : too few / too many arguments at [vl-directory-files]
: _QNEW
; ----- LISP : Call Stack -----
; [0]...LOAD-LSP <<--
;
; ----- Error around expression -----
; (GETENV "username")
; in file :
; C:\Program Files\Bricsys\BricsCAD V24 en_US\Support\on_doc_load.lsp
;
; error : too few / too many arguments at [vl-directory-files]
Any idea what I'm doing wrong?
(defun load-lsp ()
(foreach file (vl-directory-files "C:\\Users\\" (getenv "username") "\\J.A. van Gisbergen B.V\\WVB overleg - Documenten\\Bricscad\\Support" "*.lsp" 1)
(load (strcat "C:\\Users\\" (getenv "username") "\\J.A. van Gisbergen B.V\\WVB overleg - Documenten\\Bricscad\\Support\\" file))
)
)
(load-lsp)
But this has the following error:
_QNEW
; ----- LISP : Call Stack -----
; [0]...LOAD-LSP <<--
;
; ----- Error around expression -----
; (GETENV "username")
; in file :
; C:\Program Files\Bricsys\BricsCAD V24 en_US\Support\on_doc_load.lsp
;
; error : too few / too many arguments at [vl-directory-files]
: _QNEW
; ----- LISP : Call Stack -----
; [0]...LOAD-LSP <<--
;
; ----- Error around expression -----
; (GETENV "username")
; in file :
; C:\Program Files\Bricsys\BricsCAD V24 en_US\Support\on_doc_load.lsp
;
; error : too few / too many arguments at [vl-directory-files]
Any idea what I'm doing wrong?
0
Comments
-
Try
(foreach file (vl-directory-files (strcat "C:\\Users\\" (getenv "username") "\\J.A. van Gisbergen B.V\\WVB overleg - Documenten\\Bricscad\\Support") "*.lsp" 1)
0 -
That's the trick, thank you!0
-
I have another related question. I'm trying to add a support path via the script below, but I get an error message.
defun LM:sfsp+ ( lst )
( (lambda ( str lst )
(if (setq lst
(vl-remove-if
'(lambda ( x )
(or (vl-string-search (strcase x) (strcase str))
(not (findfile x))
)
)
lst
)
)
(setenv "ACAD" (strcat str ";" (apply 'strcat (mapcar '(lambda ( x ) (strcat x ";")) lst))))
)
)
(vl-string-right-trim ";" (getenv "ACAD"))
(mapcar '(lambda ( x ) (vl-string-right-trim "\\" (vl-string-translate "/" "\\" x))) lst)
)
)
(LM:sfsp+ '((strcat (getenv "userprofile") "\\J.A. van Gisbergen B.V\\Werkvoorbereiding - Documenten\\Bricscad\\vangisbergen\\dwg") ))
The error message i get:
; ----- LISP : Call Stack -----
; [0]...LM:SFSP+ <<--
;
; ----- Error around expression -----
; (VL-STRING-TRANSLATE "/" "\\" X)
; in file :
; C:\Users\hansk\J.A. van Gisbergen B.V\Werkvoorbereiding - Documenten\Bricscad\Support\supportpath.lsp
;
; error : bad argument type <(STRCAT (GETENV "userprofile") "\J.A. van Gisbergen B.V\Werkvoorbereiding - Documenten\Bricscad\vangisbergen\dwg")> ; expected at [vl-string-trim]0 -
Try This:
(LM:sfsp+ (list (strcat (getenv "userprofile") "\\J.A. van Gisbergen B.V\\Werkvoorbereiding - Documenten\\Bricscad\\vangisbergen\\dwg")) )0