Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

Is it just to move Xrefs lay on layer to another or changing all objects within an Xref to one layer ???

Posted

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 :D

Posted

Hi Tharwat,

the idea is to get all the xrefs into one layer.

Posted
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)
)

Posted

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?

Posted
Tharwat,

found this, which seems to work:

 

Mine did not work for you ?

Posted

For fun :playing::

 

(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))

Posted

@Renderman , what about changing the layer that they are laying on ? :)

Posted
@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. :thumbsup:

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...