Lisp to Xref a file into a drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I'm working on writing my first lisp. It is going to go through a few dozen file names and any of them that exist in a folder it is going to xref them into the drawing. Part of this means that the user's current drawing might be one of those few dozen files. One of those files might already be xrefed into the drawing. And one of the file names might not exist in the folder.
I was going to just copy and paste this code for each xref to look for.
(defun c:autoxref ()
(setq proj (getvar 'dwgprefix))
(setq cur (getvar "dwgname"))
;Xref 1 define file name and reference name;
(setq reffile ("ham.dwg"))
(setq refname ("ham"))
(setq full (strcat proj reffile))
;Does this file exist? Is this trying to xref the file to itself? Is it currently Xrefed?
(if (findfile (full)), (if (dwgname = reffile), (if ((and(setq data (tblsearch "block" refname))(= 4 (logand 4 (cdr (assoc 70 data)))))), command "-xref" "r" refname), (command "-xref" "o" full "0" "1" "1" "0")))
)
In this code the file is ham.dwg. The xref files are stored in the same directory. I was trying to get it to check if the file exists, then check if it is the same as the current drawing name, then check to see if it it was currently xrefed. If it was currently xrefed it would reload the xref. If it was not it would xref it as an overlay. If the file did not exist or was the same as the current drawing name it would move on to the next file.
I'm sure it's full of errors but the one I am really struggling with is (setq refname ("ham")) is returning ; error: bad function: "ham". I'd appreciate it if anyone could help point me in the right direction.
Thanks,
AT