Jump to content

Recommended Posts

Posted

image.thumb.png.aef761d4c052c0382c2caf1cf70a4f5b.png

 

Hi everyone,

I’m working on a project with multiple AutoCAD drawings (building floors), and each floor contains several XREF layers.

I want to know if there is a way or tool to change XREF layer properties (such as color, linetype, lineweight, etc.) for multiple drawings at once without opening each file individually.

For example:

I have many floor plans.

Each drawing has the same XREF attached.

I want to directly modify the XREF layer overrides across all drawings in bulk.

Is there a built-in AutoCAD feature, script, LISP, Sheet Set method, Layer States Manager workflow, or Autodesk tool that can do this automatically?

 

Posted

You can use possibly OBDX which can edit a dwg without opening it. Using a script is much simpler as it will open a dwg make the edits then close it. Should be reasonably fast.

 

The obvious first step is what are you trying to change ? You need say a text file with the new settings, layer name, color, linetype on/off and so on.

 

So if I understand correct another way, the sequence may be open a dwg add the xref do the layer changes save and close do next dwg. So what I am asking here does original dwg always have the xref pre loaded.

 

Need sample dwg, txt and a xref. Can be blank just need layers,

 

 

Posted

hello 
actually we attach the architectural drawings as xref 
after finishing our mechanical plans we have to publish so we got to change xref's layers properties excpt for title block(which is also xref) 

 

Posted (edited)

@ababs "actually we attach the architectural drawings as xref " so why not do the changes then as part of an custom attach xref lisp. 

 

Again need an idea of what the layer names are and the relevant changes. How do you propose to identify the layers ? By wildcards "wall*" etc Were I worked we redid the color of layers by wildcards about 7 of them. So maybe 50 layers.

Edited by BIGAL
Posted

Hi Again

for example, here I have 4 xref attached, I need to change the layers properties (make color 180,180,180 and line weight =default) for these xrefs without opening all drawings. Thank you for your time
image.thumb.png.16168b8e4935fb2bd9badf6af61772a4.png

Posted (edited)

So give this a try. Just load the xrefs in a dwg then run this code will reset all the xref layers. Note will do all current XREFS. Just do it as part of adding the XREFS to current dwg.

 

; https://www.cadtutor.net/forum/topic/99138-layer-properties/
; Set all xref colors in a dwg
; By AlanH May 2026

(defun c:setxrefcol ( / lst blk lays xname tc)

(setq lst '())
(setq blk (tblnext "BLOCK" T))
(while blk
  (if (member (logand (cdr (assoc 70 blk)) 4) '(4)) ; bit‑4 = xref
  (setq lst (cons (cdr (assoc 2 blk)) lst))
  )
  (setq blk (tblnext "BLOCK"))
)
(reverse lst)

(setq lays  (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))

(repeat (setq x (length lst))
  (setq xname (nth (setq x (1- x)) lst))
  (vlax-for lay lays
  (setq lname (vlax-get lay 'name))
  (if (wcmatch lname (strcat "*" lname "*"))
  (progn
    (setq tc (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.20"))
    (vla-SetRGB tc 180 180 180)
    (vla-put-TrueColor lay tc)
  )
  )
  )
)

(princ)
)

(c:setxrefcol)

 

There is no need to try and do it as a after task.

Edited by BIGAL
Posted

Thank you, but I am looking for something more general (I don’t think a LISP will solve the problem).

I remember seeing something on YouTube where we can control layer properties without opening the drawings.

I uploaded the picture for this specific XREF (x-A2-landscape). I don’t want to change  these properties for this xref .......

Your LISP is too specific because, on some floors, more or fewer architectural XREFs are attached.

 

image.png

Posted (edited)

I understand there are ways of selecting which XREFS you want to change. 

 

; Set all xref colors in a dwg
; By AlanH May 2026
; Multi choice added by AlanH

(defun c:setxrefcol ( / lst blk lays xname tc)

(setq lst '())

(setq blk (tblnext "BLOCK" T))

(while blk
  (if (member (logand (cdr (assoc 70 blk)) 4) '(4)) ; bit‑4 = xref
  (setq lst (cons (cdr (assoc 2 blk)) lst))
  )
  (setq blk (tblnext "BLOCK"))
)

(if (not AH:Toggs)(load "Multiple toggles.lsp"))
(setq ans (reverse (ah:toggs (cons "Choose Xrefs " lst))))

(setq lays  (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
(setq tc (vla-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.20"))
(setq lst2 '())

(repeat (setq x (length ans))
  (if (= (nth (setq x (1- x)) ans) "1")
  (setq lst2 (cons (nth x lst) lst2))
  )
)

(foreach lname lst2
 (vlax-for lay lays
  (if (wcmatch (vlax-get lay 'name) (strcat "*" lname "*"))
    (progn
	(if (= lname "Defpoints")(alert "defpoints"))
      (vla-SetRGB tc 180 180 180)
      (vla-put-TrueColor lay tc)
    )
  )
 )
)

(princ)
)
(c:setxrefcol)

 

You must save multi Toggles.lsp in a support path as its auto loaded, it will display the names of your xref's, up to about 20 xref's by name, then just tick on the ones you want to change.

 

Multi toggles.lsp

 

Edited by BIGAL
  • 1 month later...
Posted
On 5/22/2026 at 7:24 AM, ababs said:

 

Hi everyone,

I’m working on a project with multiple AutoCAD drawings (building floors), and each floor contains several XREF layers.

I want to know if there is a way or tool to change XREF layer properties (such as color, linetype, lineweight, etc.) for multiple drawings at once without opening each file individually.

For example:

I have many floor plans.

Each drawing has the same XREF attached.

I want to directly modify the XREF layer overrides across all drawings in bulk.

Is there a built-in AutoCAD feature, script, LISP, Sheet Set method, Layer States Manager workflow, or Autodesk tool that can do this automatically?

You can have multiple references to the same drawing with different Layer Properties. I've done it many times.

 

You could insert the same XREF drawing into one of your project drawing with a different name, modify it's layer properties then copy each of them into your project drawings.

 

You could also define Layer States in the XREF drawing for both Layer States in the XREF drawing then insert and name each of them into one of your project drawings then just copy each of those inserts to the rest of your project drawing.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...