View Full Version : Xref Selection
tonyv
2009-08-06, 09:38 PM
I have a group of xref's that I want to insert into a drawing but autocad only allows me to select them one at a time. Is there a setting which will allow me to select all that I need and load them into my drawing at once? I am using 2010.
rkmcswain
2016-06-01, 12:30 PM
See this:
https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Inserting-multiple-XREFs-in-AutoCAD-2010-s.html
See this:
https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Inserting-multiple-XREFs-in-AutoCAD-2010-s.html
The excuse of a reason on that article is quite lame. You mean to tell me they can't figure out how to attach more than one file format at a time?
rkmcswain
2016-06-01, 01:08 PM
Who knows if it's even true. I have to question the QA/QC process on these KB articles sometimes.
BlackBox
2016-06-01, 04:33 PM
I wrote this back in 2010, and has served me well - in short, this will prompt user for multiple drawing selection relative to the active drawing, check/set the desired Layer, reload XREFs that are already attached, and send them to the back:
*DOSLib required*
(defun c:XX () (c:XrefUnderlay))
(defun c:XrefUnderlay (/ *error* flag xrefs ss acDoc layerName oLayer
insertionPoint xrefName oXref space layerName
)
(princ "\rXREFUNDERLAY \n")
(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if (and (setq flag (dos_version))
(setq xrefs
(dos_getfilem
"Select reference file to underlay"
(if *XrefUnderlay_LastPath*
*XrefUnderlay_LastPath*
(getvar 'dwgprefix)
)
"Drawing files (*.dwg)|*.dwg|All files (*.*)|*.*||"
)
)
(setq *XrefUnderlay_LastPath* (car xrefs))
(setq ss (ssadd))
)
(progn
(vla-startundomark
(setq acDoc (vla-get-activeDocument (vlax-get-acad-object)))
)
;; layer check, will create layer if it does not already exist
(setq oLayer (vla-add (vla-get-layers acDoc)
(setq layerName "XREF")
)
)
(vla-put-color oLayer 8)
(vla-put-description oLayer "Reference File Attachments ")
;;<-- more layer properties here
(setq space
(vlax-get acDoc
(if (= 1 (getvar 'cvport))
'paperspace
'modelspace
)
)
)
(setq insertionPoint (vlax-3d-point '(0 0 0)))
(foreach xref (cdr xrefs)
(setq xref (strcat *XrefUnderlay_LastPath* xref))
(if (tblsearch "block"
(setq xrefName (vl-filename-base xref))
)
(progn
(prompt "\nReference already exists, reloading... ")
(vl-catch-all-apply
'vla-reload
(list
(setq oXref (vla-item (vla-get-blocks acDoc) xrefName))
)
)
(princ "Done. ")
)
(progn
(prompt (strcat "\nAttaching \"" xrefName "\" reference... ")
)
(setq oXref
(vla-attachexternalreference
space xref xrefName insertionPoint 1. 1. 1. 0.
:vlax-true
)
)
(vla-put-layer oXref layerName)
(ssadd (vlax-vla-object->ename oXref) ss)
(princ "Done. ")
)
)
)
(sssetfirst nil ss)
(ai_draworder "_b")
)
(cond (flag)
((prompt "\n** DOSLib must be loaded ** "))
)
)
(*error* nil)
)
HTH
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.