Hello everyone,
I am looking for a lisp that would MAKE NEW LAYER (named x-ref or whatever- color white ie.), SELECT all external references, MOVE them to that layer and LOCK it.
I have number of files with many x-ref files that are on different layer. Many people worked on them and match properties was vastly used and now I have xrefs placed on defpoints, dimension layer, etc...
I am not to familiar with tweaking the codes so although i have found some similar posts I am cant compile what I need.
Thanks in advance
Cheers
Janko
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Mike,
again untested,
change
(not (wcmatch (car lay) "--XR-UNLOCKED"))
to
(not (wcmatch (cdr (assoc 2 (car lay))) "--XR-UNLOCKED"))
hope that helps
Henrique
Guys,
I am using this routine extensivly and it makes me happy 🙂
I would like to modify it a bit, but i am not sure which line should I change... I want newly made layer XREF_LAY to be NON-printing...
(defun c:XRL (/ ENT I L LAY LAYLST LAYX SS) (if (setq ss (ssget "_X" '((0 . "INSERT")))) (progn (if (and (setq l (tblobjname "layer" "XREF_LAY")) (setq layx (entget l)) ) (if (/= 4 (logand 4 (cdr (assoc 70 layx)))) (setq laylst (cons (cons layx 4) laylst)) ) ) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "XREF_LAY") (cons 70 4) ) ) (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i))))) (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 ent))))) ) ) (progn (setq lay (entget (tblobjname "layer" (cdr (assoc 8 ent))))) (if (= 4 (logand 4 (cdr (assoc 70 lay)))) (progn (setq laylst (cons (cons lay (cdr (assoc 70 lay))) laylst)) (entmod (subst (cons 70 0) (assoc 70 lay) lay)) ) ) (entmod (subst (cons 8 "XREF_LAY") (assoc 8 ent) ent)) ) ) ) (if laylst (foreach lay laylst (entmod (subst (cons 70 (cdr lay)) (assoc 70 (car lay)) (car lay))) ) ) ) ) (princ) )
Thanks!
JAN
@jahbgd wrote:
Guys,
I am using this routine extensivly and it makes me happy 🙂
I would like to modify it a bit, but i am not sure which line should I change... I want newly made layer XREF_LAY to be NON-printing...
...
Hi Jan,
I don't have AutoCAD at this moment, so untested, but should work as expected
Change the entmake to this one
(entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "XREF_LAY") (cons 70 4) (cons 290 0);; non-printing ) )
HTH
Henrique
Thanks Henrique,
It works, but unfortunately I realized that it selects all xrefs (which was the requirement for previous routine...)
Is it too complicated to insert an option to choose xref instead of automatically getting all xrefs?
Cheers
JaN
@jahbgd wrote:
...
Is it too complicated to insert an option to choose xref instead of automatically getting all xrefs?
...
Just remove the selection mode "_X" from the ssget function...
(defun c:XRL (/ ENT I L LAY LAYLST LAYX SS) (if (setq ss (ssget '((0 . "INSERT")))) (progn
HTH
Henrique
Hello everyone,
After flawlesly using this routine for some time, today I got message
; error: bad argument type: stringp nil
I have no idea, what could have happened... I tried reloading routine, restarting autocad, but it ddnt help. I was checking other posts with same issue, but couldnt find connection of a reason.
Any ideas?
Jan
@jahbgd wrote:
Hello everyone,
After flawlesly using this routine for some time, today I got message
; error: bad argument type: stringp nil
I have no idea, what could have happened... I tried reloading routine, restarting autocad, but it ddnt help. I was checking other posts with same issue, but couldnt find connection of a reason.
Any ideas?
Jan
Hi Jan,
the '; error: bad argument type: stringp nil'
means that a function is expecting a string argument and has received a nil...
As we don't know which of the codes you are using, it would help if you post the code.
Henrique
Here it goes...
(defun c:XRL (/ ENT I L LAY LAYLST LAYX SS) (if (setq ss (ssget "_X" '((0 . "INSERT")))) (progn (if (and (setq l (tblobjname "layer" "A-G-G-Bldg")) (setq layx (entget l)) ) (if (/= 4 (logand 4 (cdr (assoc 70 layx)))) (setq laylst (cons (cons layx 4) laylst)) ) ) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "A-G-G-Bldg") (cons 70 4) ) ) (repeat (setq i (sslength ss)) (setq ent (entget (ssname ss (setq i (1- i))))) (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 ent))))) ) ) (progn (setq lay (entget (tblobjname "layer" (cdr (assoc 8 ent))))) (if (= 4 (logand 4 (cdr (assoc 70 lay)))) (progn (setq laylst (cons (cons lay (cdr (assoc 70 lay))) laylst)) (entmod (subst (cons 70 0) (assoc 70 lay) lay)) ) ) (entmod (subst (cons 8 "A-G-G-Bldg") (assoc 8 ent) ent)) ) ) ) (if laylst (foreach lay laylst (entmod (subst (cons 70 (cdr lay)) (assoc 70 (car lay)) (car lay))) ) ) ) ) (princ) )
thanks
Lots of ways to locate your lack-of-string error.
One way is to load, ie execute, the routine in the Vlide.
Another is to insert PRINC statements, ie:
(princ " 1: ") (princ " 2: ") (princ " 3: ")...etc
before lines that use a string argument.
Jan,
As stevor already suggested, try using VLIDE to debug the code, this Lee Mac's tutorial may be useful.
Henrique
I will try it in VLIDE... although the strange thing is that routine works on other computers. My colleagues dont have that problem, so I was suspecting some autocad glitch.
Thank you
Jan,
are you loading the routine manually, or via acadxxx.lisp, or Startup Suite, or...
Just for testing, drag and drop the .lsp file in the dwg and try to run the code, it still giving error?
Henrique