Lisp help Please

Status
Not open for further replies.

Donald Varino

Usenet Archive
Joined
Jan 21, 2001
Messages
26
Reaction score
0
I'm new to LISP and I wrote this routine that will look and find the correct drawing to xref into my drawing, the only catch is that I also want it o look to see if that drawing is already loaded (xref'ed) or if there is a block occurance in the drawing that will cause this to be a circular reference. Any help would be greatly appreciated I use Autocad R14 and 2002

See code here......

(defun c:xrr (/ savecmd dir dwgname dwgnumb partname newname dirdwgname blk_def blk_lst) (setq savecmd (getvar "cmdecho")) (setq dir (getvar "dwgprefix")) (setq dwgname (getvar "dwgname")) (setq dwgnumb (substr dwgname 5 6)) (setq partname "O_FP") (setq newname (strcat partname dwgnumb)) (setq dirdwgname (strcat dir newname)) (setq blk_def (tblnext "block" T)) (setq blk_lst (cdr (assoc 1 blk_def))) (if (or (= newname blk_lst) (alert "XREF already attached. Try RELOADing instead")) (alert "There is already a block in the drawing with that name, please PURGE") (command) (command ".xref" "a" dirdwgname "0,0" "" "" "")) (command "zoom" "extents") (setvar "cmdecho" savecmd) (princ)
)

Donald
 
(if (tblsearch "block" "BlockName")
(alert "Block already exists)
(progn
(do whatever here)
);;progn
);;if

Blocks are blocks, whether XRef'd or not, and if one's already in the block table you won't be able to XRef it. You can check any block in the block table to see if it's XRef'd or not by evaluating bit 2 (value = 4) of group code 70 in the block table:

(setq blk (entget (tblobjname "block" "BlockName")))
(if (= (logand (cdr (assoc 70 blk)) 4) 4)
(alert "Block is externally referenced")
(alert "Block is NOT externally referenced.")
);;if
___

"Donald Varino" wrote:

I'm new to LISP and I wrote this routine that will look and find the
correct
drawing to xref into my drawing, the
only catch is that I also want it o look to see if that drawing is already loaded (xref'ed) or if there is a block occurance in the drawing that will cause this to be a circular reference. Any help would be greatly
appreciated
I use Autocad R14 and 2002

See code here......

(defun c:xrr (/ savecmd dir dwgname dwgnumb partname newname dirdwgname blk_def blk_lst) (setq savecmd (getvar "cmdecho")) (setq dir (getvar "dwgprefix")) (setq dwgname (getvar "dwgname")) (setq dwgnumb (substr dwgname 5 6)) (setq partname "O_FP") (setq newname (strcat partname dwgnumb))
...
 
Oops ....
(if (tblsearch "block" "BlockName")
(alert "Block already exists.")
(progn
(do whatever here)
);;progn
);;if
___

"Paul Turvill" wrote:

(if (tblsearch "block" "BlockName")
(alert "Block already exists)
(progn
(do whatever here)
);;progn
);;if
 
Status
Not open for further replies.

Latest threads

Back
Top