Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Moving xRefs to another layer

24 REPLIES 24
Reply
Message 1 of 25
TimDelbaereGCP
5497 Views, 24 Replies

Moving xRefs to another layer

Hi All,

 

I have been looking around the web to find a quick lsp routine that will take all the xrefs in a drawings and move them back onto layer "xref" or "0" depending on what the design team wants.

 

The ones I have found don't work or move all the xrefs to seperate layers.

 

Does anyone know of any that I can use or know where to look for them?

 

Thanks again for you help.

 

Tags (2)
24 REPLIES 24
Message 21 of 25
_Tharwat
in reply to: andreas7ZYXQ

Sorry my last reply was not that complete so please consider the following instead:

 

(vl-load-com)
(defun c:Test (/ ss i vla)
  ;; Tharwat 31. Oct. 2011 ;;
  (if (and (or (tblsearch "LAYER" "x-ref")
               (entmake (list '(0 . "LAYER")
                              '(100 . "AcDbSymbolTableRecord")
                              '(100 . "AcDbLayerTableRecord")
                              (cons 2 "x-ref")
                              '(70 . 0)
                        )
               )
           )
           (setq ss (ssget "_X" '((0 . "INSERT"))))
      )
    (repeat
      (setq i (sslength ss))
       (setq vla (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
       (if (vlax-property-available-p vla 'Path)
         (vla-put-layer vla "x-ref")
       )
    )
    (princ)
  )
  (princ)
)
Message 22 of 25
andreas7ZYXQ
in reply to: _Tharwat

Im looking for a small edit on this.

If i would like to select the xref first and when i clicked i want to move it to layer "xref" and change its colour.

User input:
Start command
Select xref 
xref moves to layer "xref"
changes color to 9

Anyone have an idea for edit on this?
thanks in advance

Message 23 of 25
dlanorh
in reply to: andreas7ZYXQ

A single selection or a loop of single selections?

 

Change the color of the layer the xref is on and/or every layer in the xref as per HERE ?

I am not one of the robots you're looking for

Message 24 of 25
andreas7ZYXQ
in reply to: dlanorh

A single selection, and change the color of every layer in the xref is what i had in mind.

Message 25 of 25
dlanorh
in reply to: andreas7ZYXQ

Try this. A quick amalgam of @_Tharwat 's and @ronjonp 's code from above link in my post

 

(vl-load-com)
(defun c:Test (/ doc ss i vla)
  ;; Tharwat 31. Oct. 2011 ;;
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  
  (cond ( (or (tblsearch "LAYER" "x-ref")
              (entmake  (list '(0 . "LAYER")
                              '(100 . "AcDbSymbolTableRecord")
                              '(100 . "AcDbLayerTableRecord")
                               (cons 2 "x-ref")
                              '(70 . 0)
                        )
              )
          )
          (prompt "\nSelect XRef : ")
          (setq ss (ssget "_+.:E:S:L" '((0 . "INSERT"))))
          (setq vla (vlax-ename->vla-object (ssname ss 0)))
          (cond ( (vlax-property-available-p vla 'Path)
                  (setq blk (vlax-get vla (if (vlax-property-available-p vla 'effectivename) 'effectivename 'name)))
                  (vlax-for lyr (vla-get-layers doc)
                    (and (wcmatch (vla-get-name lyr) (strcat blk "|*")) (vla-put-color lyr 9))
                  )
                  (vla-put-layer vla "x-ref")
                )
          )
          (vla-regen doc acactiveviewport)
          (princ)
        )
  )
  (princ)
)

This won't change the color of xref object that aren't bylayer or byblock

I am not one of the robots you're looking for

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost