daisenson Posted May 23, 2012 Posted May 23, 2012 Hi Everyone, I'm trying to find a script to batch run that will selecta all the xrefs in a drawing and will put them in one layer. Has anyone know how to do this? Thkx Quote
BlackBox Posted May 23, 2012 Posted May 23, 2012 Create a selection set of block entities, then iterate testing for the IsXref Propoerty of the Block Object, then, if successful, modify the Block Object's Layer Property. FWIW - I personally use a Command Reactor to automagically set the appropriate layer current when a user attaches Xrefs, Images, Pdfs, etc. then once the Command has Ended, Cancelled, etc. the original layer is restored. This may be of use to you as well, as you learn to do more with Visual LISP. HTH Quote
Tharwat Posted May 23, 2012 Posted May 23, 2012 Is it just to move Xrefs lay on layer to another or changing all objects within an Xref to one layer ??? Quote
Blackfish Posted May 23, 2012 Posted May 23, 2012 Does it need to be a script? If it is in one drawing use QSELECT to select all xrefs and than change layer for all of them in one go. It's only six clicks, but probably five too many Quote
daisenson Posted May 23, 2012 Author Posted May 23, 2012 Hi Tharwat, the idea is to get all the xrefs into one layer. Quote
Tharwat Posted May 23, 2012 Posted May 23, 2012 Hi Tharwat,the idea is to get all the xrefs into one layer. This ... ? (defun c:Test (/ layer found ss i sn vl) (vl-load-com) (if (and (/= (setq Layer (getstring t "\n Enter name of Layer :")) "" ) (setq found (tblsearch "LAYER" Layer)) (setq ss (ssget "_x" '((0 . "INSERT")))) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (if (vlax-property-available-p (setq vl (vlax-ename->vla-object sn)) 'Path ) (vla-put-layer vl LAYER) ) ) (cond ((not found) (princ "\n Layer name is not found in Layer List ") ) (t (princ "\n No Xrefs files found in drawing ")) ) ) (princ) ) Quote
daisenson Posted May 23, 2012 Author Posted May 23, 2012 Tharwat, found this, which seems to work: (defun c:xreflayer (/ tdef xl) (while (setq tdef (tblnext "BLOCK" (not tdef))) (if (= (logand (cdr (assoc 70 tdef)) 4) 4) (setq xl (cons (cdr (assoc 2 tdef)) xl)))) (foreach b xl (if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 b)))) (command "_.CHPROP" ss "" "_LA" "LAYER_NAME" "")))) I'm not versed in lisp, just a very few basiscs, has your code visual lisp, while this bit isn't? Quote
SLW210 Posted May 23, 2012 Posted May 23, 2012 daisenson, Please read the CODE POSTING GUIDELINES and edit your post! Quote
Tharwat Posted May 23, 2012 Posted May 23, 2012 Tharwat,found this, which seems to work: Mine did not work for you ? Quote
BlackBox Posted May 23, 2012 Posted May 23, 2012 For fun : (defun c:SelectXrefs (/ xrefs ss) (vl-load-com) (setq xrefs "") (vlax-for x (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-true (vla-get-isxref x)) (setq xrefs (strcat xrefs (vla-get-name x) ",")))) (if (setq ss (ssget "_x" (list '(0 . "INSERT") (cons 2 (vl-string-right-trim "," xrefs))))) (sssetfirst nil ss) (prompt "\n** No external references found ** ")) (princ)) Quote
Tharwat Posted May 23, 2012 Posted May 23, 2012 @Renderman , what about changing the layer that they are laying on ? Quote
BlackBox Posted May 23, 2012 Posted May 23, 2012 @Renderman , what about changing the layer that they are laying on ? My code assumes that the end user is not inept, and will see that the Xrefs have been selected (given the aptly named function), and can do with the selected Xrefs what they please... Change layer, Copy, etc. 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.