charlielgolden
2007-10-18, 04:10 PM
I have a lsp that has worked on previous versions of autocad (200, 2000i,2004) but does not work on 2006.
;**************************************************************************8
; xfix.LSP
;
; XREF updates - changes the insertion layer of all xrefs to their file name
; and locks the layer
;
;***************************************************************************
;;********************************************************
;; Load up the list box
(defun get_xrefs_ins ()
(setq XLIST '())
(setq XTEMP (tblnext "block" t))
(setq XLIST (append XLIST (list (cons -4 "<OR"))))
(while XTEMP
(if (cdr (assoc 1 XTEMP))
(setq XLIST (append XLIST (list (assoc 2 XTEMP))))
)
(setq XTEMP (tblnext "block"))
)
(setq XLIST (append XLIST (list (cons -4 "OR>"))))
)
;;********************************************************
;; Get all references of an xref in the drawing
(defun c:xfix (/ Kount Kount2 entas refs locklist)
(setq Kount 0)
(setq Kount2 0)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq list1 '())
(get_xrefs_ins)
(if (setq refs (ssget "X" XLIST))
(progn
(princ
"\nFinding insertion layers of all xrefs - please wait"
)
(while (< Kount (sslength refs))
(setq entas (entget (ssname refs Kount)))
(setq locklist (cdr (assoc 8 entas)))
(setq list1 (cons locklist list1))
(if (/= (cdr (assoc 2 entas)) (cdr (assoc 8 entas)))
(progn
(setq entas (subst (cons 8 (cdr (assoc 2 entas)))
(assoc 8 entas)
entas
)
)
(entmod entas)
(setq Kount2 (1+ Kount2))
) ;progn
) ;IF
(setq Kount (1+ Kount))
) ; while
) ; progn
) ; if
(princ "\nNow Locking the Xref Layers")
(foreach laylist list1
(command "-layer" "Lock" laylist "")
)
(if (> Kount 0)
(princ (strcat "\nFixed the insertion layers of "
(itoa Kount2)
" out of "
(itoa kount)
" total xrefs."
)
)
) ;if Kount >0
(setvar "cmdecho" oldcmdecho)
(princ)
) ; xref-fix
Any one help?
;**************************************************************************8
; xfix.LSP
;
; XREF updates - changes the insertion layer of all xrefs to their file name
; and locks the layer
;
;***************************************************************************
;;********************************************************
;; Load up the list box
(defun get_xrefs_ins ()
(setq XLIST '())
(setq XTEMP (tblnext "block" t))
(setq XLIST (append XLIST (list (cons -4 "<OR"))))
(while XTEMP
(if (cdr (assoc 1 XTEMP))
(setq XLIST (append XLIST (list (assoc 2 XTEMP))))
)
(setq XTEMP (tblnext "block"))
)
(setq XLIST (append XLIST (list (cons -4 "OR>"))))
)
;;********************************************************
;; Get all references of an xref in the drawing
(defun c:xfix (/ Kount Kount2 entas refs locklist)
(setq Kount 0)
(setq Kount2 0)
(setq oldcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq list1 '())
(get_xrefs_ins)
(if (setq refs (ssget "X" XLIST))
(progn
(princ
"\nFinding insertion layers of all xrefs - please wait"
)
(while (< Kount (sslength refs))
(setq entas (entget (ssname refs Kount)))
(setq locklist (cdr (assoc 8 entas)))
(setq list1 (cons locklist list1))
(if (/= (cdr (assoc 2 entas)) (cdr (assoc 8 entas)))
(progn
(setq entas (subst (cons 8 (cdr (assoc 2 entas)))
(assoc 8 entas)
entas
)
)
(entmod entas)
(setq Kount2 (1+ Kount2))
) ;progn
) ;IF
(setq Kount (1+ Kount))
) ; while
) ; progn
) ; if
(princ "\nNow Locking the Xref Layers")
(foreach laylist list1
(command "-layer" "Lock" laylist "")
)
(if (> Kount 0)
(princ (strcat "\nFixed the insertion layers of "
(itoa Kount2)
" out of "
(itoa kount)
" total xrefs."
)
)
) ;if Kount >0
(setvar "cmdecho" oldcmdecho)
(princ)
) ; xref-fix
Any one help?