Still looking for help on this

Status
Not open for further replies.

Donald Varino

Usenet Archive
Joined
Jan 21, 2001
Messages
26
Reaction score
0
I having a little trouble with this lisp. PLease help!!!!! I use autocadr 14 and 2002

This lisp will automatically xref in the correct drawing based on the currect drawings name. The only thing I would like for this to do is if there is an xref already in the drawing, it will alert you and suggest to you to re-load instead. Also if there is a block occurrence in the drawing with the same name as the xref that you are trying to xref in causing a circular reference it will alert you and tell you so.

Any help would be greatly appreciated.

Don

(defun c:ir (/ savecmd dir dwgname dwgnumb partname newname dirdwgname blk_def blk_lst) (setq savecmd (getvar "cmdecho")) (setq dir (getvar "dwgprefix")) ;;get path of drawing (setq dwgname (getvar "dwgname")) ;;get drawing name (setq dwgnumb (substr dwgname 5 6)) ;;get drawing floor ie. 01, 02, 03 etc. (setq partname "O_FP") ;;set new drawing prefix to standard (setq newname (strcat partname dwgnumb)) ;;combine drawing prefix w/drawing floor ie. O_FP01 (setq dirdwgname (strcat dir newname)) ;;combine path w/drawing name (setq blk_def (tblnext "block" T)) (setq blk_lst (cdr (assoc 1 blk_def))) ;(if ; (= newname blk_lst) ; (alert "The XREF is already Attached.. Try RELOADing it instead") ;(exit)) ;(if ; (= newname nil) (command ".xref" "a" dirdwgname "0,0" "" "" "") ;;XREF in correct drawing (command "zoom" "extents") (command "zoom" ".5x") (setvar "cmdecho" savecmd) ;(xrpath) (princ) ) (defun Xrpath (/ BLKNAM CNT XNAME) ;;strips off xref's path (setq CNT 1) (while (setq BLKNAM (tblnext "BLOCK" CNT)) (setq CNT nil) (if (and (/= (assoc 1 BLKNAM) nil) (> (- (strlen (cdr (assoc 1 BLKNAM))) 4) (strlen (cdr (assoc 2 BLKNAM))) ) ) (command "xref" "path" (cdr (assoc 2 BLKNAM)) (cdr (assoc 2 BLKNAM)) ) ) ) (princ)
)

Don
 
Just taking a quick look at what you've got here, down to the part you've commented out with semicolons, it looks like the wrong DXF code for a block name is in there. The correct DXF code for a block name would be 2 - not 1. 1 is the DXF code for text and attribute values. Therefore this code:
(setq blk_lst (cdr (assoc 1 blk_def)))
I think should look like this:
(setq blk_lst (cdr (assoc 2 blk_def)))
 
... the (if ...) clauses also lack (progn ...) functions for grouping arguments.
___

"Bill DeShawn" wrote:

Just taking a quick look at what you've got here, down to the part you've commented out with semicolons, it looks like the wrong DXF code for a
block
name is in there. The correct DXF code for a block name would be 2 - not
1.
1 is the DXF code for text and attribute values. Therefore this code:
(setq blk_lst (cdr (assoc 1 blk_def)))
I think should look like this:
(setq blk_lst (cdr (assoc 2 blk_def)))
autocadr
> 14 and 2002
>
> This lisp will automatically xref in the correct drawing based on the
> currect drawings name.
> The only thing I would like for this to do is if there is an xref
already
in
> the drawing, it will alert you and suggest to you to re-load instead.
Also
> if there is a block occurrence in the drawing with the same name as the xref
> that you are trying to xref in causing a circular reference it will
alert
> you and tell you so.
>
> Any help would be greatly appreciated.
>
> Don
>
>
> (defun c:ir (/ savecmd dir dwgname dwgnumb partname newname dirdwgname
> blk_def blk_lst)
> (setq savecmd (getvar "cmdecho"))
> (setq dir (getvar "dwgprefix")) ;;get path of drawing
> (setq dwgname (getvar "dwgname")) ;;get drawing name
...
drawing
> (command "zoom" "extents")
> (command "zoom" ".5x")
> (setvar "cmdecho" savecmd)
> ;(xrpath)
> (princ)
> )
> (defun Xrpath (/ BLKNAM CNT XNAME) ;;strips off xref's path
> (setq CNT 1)
> (while (setq BLKNAM (tblnext "BLOCK" CNT))
> (setq CNT nil)
> (if (and (/= (assoc 1 BLKNAM) nil)
> (> (- (strlen (cdr (assoc 1 BLKNAM))) 4)
...
 
Status
Not open for further replies.

Latest threads

Back
Top