daisenson Posted October 9, 2010 Share Posted October 9, 2010 Could anyone tell me how to select all the xrefs in a drawings and move them to a specific layer (440_XREF)? I've tried all other posts related to this topic, but unfortunately my knowledge of coding doesn't stretch further than: (setq sel1 (ssget "x" '((0 . "insert")))) this will select all blocks, including xrefs but I don't know how to filter them. thanks Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 9, 2010 Share Posted October 9, 2010 [b][color=BLACK]([/color][/b]defun c:xreflist [b][color=FUCHSIA]([/color][/b]/ tdef xl[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq tdef [b][color=MAROON]([/color][/b]tblnext [color=#2f4f4f]"BLOCK"[/color] [b][color=GREEN]([/color][/b]not tdef[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]= [b][color=GREEN]([/color][/b]logand [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 70 tdef[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] 4[b][color=GREEN])[/color][/b] 4[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq xl [b][color=GREEN]([/color][/b]cons [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 2 tdef[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] xl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] xl[b][color=BLACK])[/color][/b] You have to examine each BLOCK table defintion to determine if the BLOCK is an external reference Step through the BLOCK table definitions using (tblnext) If the BLOCK flag ( group 70 ) 4 bit is set, then add the BLOCK name ( group 2) to the list 'xl xl is a list containing the names of xrefs found The problem then lays in the fact that some of these BLOCKs may nested in other xrefs, so that CHPROP cannot manipulate the layers. Or it may be as simple as: [b][color=BLACK]([/color][/b]foreach b xl [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"INSERT"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 2 b[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.CHPROP"[/color] ss [color=#2f4f4f]""[/color] [color=#2f4f4f]"_LA"[/color] [color=#2f4f4f]"440_XREF"[/color] [color=#2f4f4f]""[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] HTH -David Quote Link to comment Share on other sites More sharing options...
daisenson Posted October 9, 2010 Author Share Posted October 9, 2010 Thanks David, It works Quote Link to comment Share on other sites More sharing options...
pBe Posted October 9, 2010 Share Posted October 9, 2010 you can also do it this way (setq xr_dwg (vla-get-activedocument (vlax-get-acad-object)) xr_blk (vla-get-blocks xr_dwg)) (vlax-for blk xr_blk (if (= (vla-get-IsXRef blk) :vlax-true) (setq xl (cons (vla-get-name blk) xl)) ) ) and used the second part of daivds Quote Link to comment Share on other sites More sharing options...
Michaels Posted October 9, 2010 Share Posted October 9, 2010 you can also do it this way (setq xr_dwg (vla-get-activedocument (vlax-get-acad-object)) xr_blk (vla-get-blocks xr_dwg)) (vlax-for blk xr_blk (if (= (vla-get-IsXRef blk) :vlax-true) (setq xl (cons (vla-get-name blk) xl)) ) ) and used the second part of daivds Great work pBe. May I ask you how to get the full path of the Xref dwg. ? Many thanks Quote Link to comment Share on other sites More sharing options...
pBe Posted October 9, 2010 Share Posted October 9, 2010 (setq xr_dwg (vla-get-activedocument (vlax-get-acad-object)) xr_blk (vla-get-blocks xr_dwg)) (vlax-for blk xr_blk (if (= (vla-get-IsXRef blk) :vlax-true)(progn (setq xl (cons (vla-get-name blk) xl)) (print (vla-get-path blk))(princ)) ) ) just add (vla-get-path ..) there you go thanks michaels Quote Link to comment Share on other sites More sharing options...
Michaels Posted October 9, 2010 Share Posted October 9, 2010 Wonderful pBe. Thank you so much For your time and for fast reply. Greatly appreciated. Michaels. Quote Link to comment Share on other sites More sharing options...
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.