setq common part of file path

setq common part of file path

Anonymous
Not applicable
1,048 Views
2 Replies
Message 1 of 3

setq common part of file path

Anonymous
Not applicable
Hello everyone 🙂 I have a long list of blocks to be inserted (100+). How can I structure my lisp to place part of the filepath in setq? e.g. This is what I have now: (defun c:001 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK001.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:002 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK002.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:003 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK003.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:004 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK004.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:005 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK005.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:006 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK006.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:007 () (command ".-insert" "C:\\folder1\\folder sub1\\folder sub2\\BLK007.dwg" pause 1 1 0 "x" "xx" "xxx")) What I'm after: (defun commonpath () (setq TBFile "C:\\folder1\\folder sub1\\folder sub2\\") ) (defun c:001 () (command ".-insert" "(commonpath) BLK001.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:002 () (command ".-insert" "(commonpath) BLK002.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:003 () (command ".-insert" "(commonpath) BLK003.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:004 () (command ".-insert" "(commonpath) BLK004.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:005 () (command ".-insert" "(commonpath) BLK005.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:006 () (command ".-insert" "(commonpath) BLK006.dwg" pause 1 1 0 "x" "xx" "xxx")) (defun c:007 () (command ".-insert" "(commonpath) BLK007.dwg" pause 1 1 0 "x" "xx" "xxx")) Thanks in advance 🙂
0 Likes
Accepted solutions (1)
1,049 Views
2 Replies
Replies (2)
Message 2 of 3

Ranjit_Singh
Advisor
Advisor
Accepted solution

Try something like this.

 

(setq 	commonpath (vl-filename-base (getfiled "" "" "" 0))
	blocknames '("blk001.dwg" "blk002.dwg" "blk003.dwg" "blk004.dwg" "blk005.dwg" "blk006.dwg" "blk007.dwg"))
(mapcar '(lambda (y) (command ".-insert" (strcat commonpath "\\" y) pause 1 1 0 "x" "xx" "xxx")) blocknames)
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks for the reply Ranjiit....this works perfect!
0 Likes