pman860507 Posted November 11, 2011 Posted November 11, 2011 I dont take any credit for this code posted below other then putting it together. I saw a topic on this a while back. i though it would be useful to share since everyone in the topic was talking about it but i dont think it was posted. this take everything from Lee Mac. just though i would share how i put it all together. used a global variable so that your default option changes each time you change your choice. unlocks all layers. changes xref layers. changes layers back to lock included xref layer. purges drawing. (defun c:XREF_LAYER ( / a b c d lay_lst ) (defun *Error* (Msg) (cond ((member Msg '("Function cancelled" "quit / exit abort"))) ((princ (strcat "Error: " Msg)) (princ "\nRestoring System Variables ") (terpri))) (princ)) (vl-load-com) (vlax-for lay (vla-get-Layers(vla-get-Activedocument (vlax-get-acad-object))) (if (= :vlax-true(vla-get-lock lay)) (progn (vla-put-lock lay :vlax-false) (setq lay_lst (cons lay lay_lst)) ) ) ) (initget "ME-ANNO-XREF E-ANNO-XREF M-ANNO-XREF P-ANNO-XREF T-ANNO-XREF F-ANNO-XREF") (setq *layr* (cond ( (getkword(strcat "\nChoose [ME/M/E/P/T/F] <"(setq *layr*(cond ( *layr* ) ( "ME" ))) ">: ")) ) ( *layr* ) ) ) (while (setq a (tblnext "BLOCK" (null a))) (if (= 4 (logand 4 (cdr (assoc 70 a)))) (setq b (cons "," (cons (cdr (assoc 2 a)) b))) ) ) (if (setq c (ssget "_X" (list (cons 0 "INSERT") (cons 2 (apply 'strcat (cdr b))) (cons 8 (strcat "~" *layr*)) ) ) ) (repeat (setq d (sslength c)) (entmod (list (cons -1 (ssname c (setq d (1- d)))) (cons 8 *layr*))) ) ) (if lay_lst(foreach l lay_lst(vla-put-lock l :vlax-true))(princ "No layers to restore")) (command "purge" "all" "" "n") (command "layer" "LO" *layr* "") (princ) ) Quote
Recommended Posts
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.