Jump to content

Recommended Posts

Posted (edited)

I need a lisp to find all xrefs and moves them onto a layer called Xrefs.

 

I attempted to do this myself ( lisps are not "my thing" at all) by editing this very useful lisp which (successfully) finds all viewports and puts them on a layer called ZPB_VPORT

 

(defun C:vpget (/ a1 b1 index b1 ln)
   (command "-layer" "m" "ZPB_VPORT" "P" "N" "ZPB_VPORT" "")    
   (setq  a1 (ssget "X" '((0 . "VIEWPORT")))))

 

I've made several attempts without success

 

Obviously I don't have a clue what I'm doing .....:(

Edited by SLW210
Added CODE TAGS!
Posted

Try this ....

 

(defun c:Test (/ xr i vl)
 (vl-load-com)
 (if (tblsearch "LAYER" "Xrefs")
   (if (setq xr (ssget "_x" '((0 . "INSERT"))))
     (repeat (setq i (sslength xr))
       (if (vlax-property-available-p (setq vl (vlax-ename->vla-object (ssname xr (setq i (1- i))))) 'Path)
         (vla-put-layer vl "Xrefs")
       )
     )
   )
   (alert "Layer < Xrefs > is not found in drawing ")
 )
 (princ)
)

Posted

Another:

([color=BLUE]defun[/color] c:xr2lay ( [color=BLUE]/[/color] bd en in la ss xr )
   
   ([color=BLUE]setq[/color] la [color=MAROON]"XRefs"[/color]) [color=GREEN];; Layer for XRefs[/color]
   
   ([color=BLUE]while[/color] ([color=BLUE]setq[/color] bd ([color=BLUE]tblnext[/color] [color=MAROON]"BLOCK"[/color] ([color=BLUE]null[/color] bd)))
       ([color=BLUE]if[/color] ([color=BLUE]=[/color] 4 ([color=BLUE]logand[/color] 4 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 70 bd))))
           ([color=BLUE]setq[/color] xr ([color=BLUE]vl-list*[/color] [color=MAROON]","[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 bd)) xr))
       )
   )
   ([color=BLUE]if[/color] ([color=BLUE]and[/color] xr ([color=BLUE]setq[/color] ss ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"INSERT"[/color]) ([color=BLUE]cons[/color] 2 ([color=BLUE]apply[/color] '[color=BLUE]strcat[/color] ([color=BLUE]cdr[/color] xr)))))))
       ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] in ([color=BLUE]sslength[/color] ss))
           ([color=BLUE]setq[/color] en ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] ss ([color=BLUE]setq[/color] in ([color=BLUE]1-[/color] in)))))
           ([color=BLUE]entmod[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 8 la) ([color=BLUE]assoc[/color] 8 en) en))
       )
   )
   ([color=BLUE]princ[/color])
)

Posted

Okay no problem I will. And thanks again for all the help on here.

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