Does anybody have any code that will select all xrefs in modelspace and bind (insert) them?
the -xref bind command requires explicit names and if I use * it will also bind my titleblock xref in paperspace which I want to avoid.
@dtiemeyer wrote:Does anybody have any code that will select all xrefs in modelspace and bind (insert) them?
the -xref bind command requires explicit names and if I use * it will also bind my titleblock xref in paperspace which I want to avoid.
(defun c:XrefBind (/ tmpObj) (vl-load-com) (vlax-for objs (vla-get-ModelSpace (vla-get-activedocument (vlax-get-acad-object)) ) (if (and (= (vla-get-ObjectName objs) "AcDbBlockReference") (vlax-property-available-p objs 'Path) (setq tmpObj (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object)) ) (vla-get-Name objs) ) ) (not (assoc 71 (entget (tblobjname "block" (vla-get-Name objs))))) ) (vla-Bind tmpObj :vlax-true) ) ) (princ) )
HTH
Works awesome, thanks. But how would I make it 'just run' without waiting for user input?
@dtiemeyer wrote:Does anybody have any code that will select all xrefs in modelspace and bind (insert) them?
the -xref bind command requires explicit names and if I use * it will also bind my titleblock xref in paperspace which I want to avoid.
Here's another way to do it [minimally tested]:
(foreach x
(mapcar 'cadr (ssnamex (ssget "_X" '((0 . "INSERT") (410 . "MODEL")))))
(setq blk (cdr (assoc 2 (entget x))))
(if (assoc 1 (tblsearch "block" blk)) (command "_.xref" "_bind" blk))
)
It finds all insertions in model space, puts them into a list of entity names, and for each one, looks at whether its entry in the Block table is an Xref by checking whether it has an "Xref path name" [the (assoc 1) entry -- regular Blocks don't have one]. If so, it binds that Xref name.
If you want it to "just run" without User input, does that mean you want to do it in all drawings that you open? Sounds dangerous, but if that's what you mean, you could include the above code in something automatic like acaddoc.lsp. Otherwise, put it into a command name as with pbejse's routine.
Hi Kent,
Thanks for that, it is exactly what I was looking for. And you're right, I did mean to 'invoke' it manually but then let the command complete without user input.
Cheers!
Dustin
@dtiemeyer wrote:Works awesome, thanks. But how would I make it 'just run' without waiting for user input?
Glad it helps
Not sure what you meant by 'just run' though.
@Anonymous wrote:can it be modified to detach unloaded Xrefs then bind all loaded xref?
Are you aware that ithe code process exclusively Model space instances of XREF? also it ignores "unreferenced" xref as it wont be included in the selection set.
Can you give more info.
Cheers
Welcome to the Forum NOD684 🙂
Thanks for the Welcome pbejse 🙂
Yes am aware of that...i even tested it.
i have a lisp before that detaches unloaded xref then binds all the loaded xref
but unfortunately its not working in 2010 version...
that is why i ask if it is possible to have such lisp