Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MOVE External references to a NEWLY made layer

56 REPLIES 56
SOLVED
Reply
Message 1 of 57
jahbgd
2298 Views, 56 Replies

MOVE External references to a NEWLY made layer

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

56 REPLIES 56
Message 41 of 57
hmsilva
in reply to: CivilSamurai

Mike,

 

again untested,

change

(not (wcmatch (car lay) "--XR-UNLOCKED"))

to

(not (wcmatch (cdr (assoc 2 (car lay))) "--XR-UNLOCKED"))

 

hope that helps

Henrique

EESignature

Message 42 of 57
CivilSamurai
in reply to: hmsilva

Worked great, thank you again.
*Mike
*Civil3D*Revit*Navisworks*ArcMAP*
Message 43 of 57
hmsilva
in reply to: CivilSamurai

You're welcome, Mike
Glad I could help

Henrique

EESignature

Message 44 of 57
jahbgd
in reply to: hmsilva

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

Message 45 of 57
hmsilva
in reply to: jahbgd


@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

 

EESignature

Message 46 of 57
jahbgd
in reply to: hmsilva

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

 

Message 47 of 57
hmsilva
in reply to: jahbgd


@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

EESignature

Message 48 of 57
jahbgd
in reply to: hmsilva

Great!

 

Really appreciate.

 

 

Message 49 of 57
hmsilva
in reply to: jahbgd

You're welcome, JaN
Glad I could help

Henrique

EESignature

Message 50 of 57
jahbgd
in reply to: m_badran

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

Message 51 of 57
hmsilva
in reply to: jahbgd


@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

EESignature

Message 52 of 57
jahbgd
in reply to: hmsilva

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

Message 53 of 57
hmsilva
in reply to: jahbgd

Jan,

unfortunately I can't reproduce that error...

 

Henrique

EESignature

Message 54 of 57
stevor
in reply to: hmsilva

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.

S
Message 55 of 57
hmsilva
in reply to: hmsilva

Jan,

 

As stevor already suggested, try using VLIDE to debug the code, this Lee Mac's tutorial may be useful.

 

Henrique

EESignature

Message 56 of 57
jahbgd
in reply to: hmsilva

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 

 

Message 57 of 57
hmsilva
in reply to: jahbgd

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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost