raptor22 Posted March 1, 2015 Share Posted March 1, 2015 Hey there, I am trying to find a method to ease a process which should be done in every drawing, I need to clean up numerous drawings which are real mess. The problems is you could find a block in several layers for instance while block "Door" should only be found in its layer "Door" you could find it in several unrelated layers with wall, stairs and son on and it needs too much time to transfer all of them to their proper layers. Is there any lisp or method to make it easier? I mean a lisp that you could choose several related blocks (different door blocks) and transfer all of them to a specific layer (door layer). Thx Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 1, 2015 Share Posted March 1, 2015 This could be done using FILTER just select a block and delete the properties like Layer and Insert then it will find all the blocks with this name then just have Properties open and pick correct layer. Quote Link to comment Share on other sites More sharing options...
raptor22 Posted March 1, 2015 Author Share Posted March 1, 2015 This could be done using FILTER just select a block and delete the properties like Layer and Insert then it will find all the blocks with this name then just have Properties open and pick correct layer. Thank you for you reply, I've already used Filter and it's a handy command the point is through using filter you can almost select all your wanted blocks but when you work on a dirty drawing blocks could be blocked in to each other you need to explode them first and work on them which sometimes end up to another mess by virtue of unexpected problems .... I just wanted to know if anyone has a better way to solve it.. even there is another type of filter by using quick select .... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 2, 2015 Share Posted March 2, 2015 Consider this just as an example . NOTES: * Replace the My-Layer-Name string with your desired Layer name . * You can add as many as you want in place of Block1,Block2 .... etc as your block names . * Your Block objects must not be Dynamic otherwise they won't be selected and you would be in need to another filter to handle this . (defun c:mtl (/ ss e i) ;;; Tharwat 02.mar.2015 ;;; (if (and (tblsearch "LAYER" "[color=red]My-Layer-Name[/color]") [color=dimgray];;; Only one layer name here [/color] (setq ss (ssget "_:L" '((0 . "INSERT") (2 . "[color=blue]Block1,Block2,Block3[/color]")))) [color=dimgray];;; A list of block names separated with a comma [/color] ) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (entmod (subst '(8 . "Layer3") (assoc 8 e) e)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Frans Posted March 2, 2015 Share Posted March 2, 2015 If you have a nested block ("door1" inside "wall1"), just redefine the original block ("door1") and all blocks ("door1") will be updated, including the nested ones Quote Link to comment Share on other sites More sharing options...
raptor22 Posted March 2, 2015 Author Share Posted March 2, 2015 If you have a nested block ("door1" inside "wall1"), just redefine the original block ("door1") and all blocks ("door1") will be updated, including the nested ones Thank you. Consider this just as an example . NOTES: * Replace the My-Layer-Name string with your desired Layer name . * You can add as many as you want in place of Block1,Block2 .... etc as your block names . * Your Block objects must not be Dynamic otherwise they won't be selected and you would be in need to another filter to handle this . (defun c:mtl (/ ss e i) ;;; Tharwat 02.mar.2015 ;;; (if (and (tblsearch "LAYER" "[color=red]My-Layer-Name[/color]") [color=dimgray];;; Only one layer name here [/color] (setq ss (ssget "_:L" '((0 . "INSERT") (2 . "[color=blue]Block1,Block2,Block3[/color]")))) [color=dimgray];;; A list of block names separated with a comma [/color] ) (repeat (setq i (sslength ss)) (setq e (entget (ssname ss (setq i (1- i))))) (entmod (subst '(8 . "Layer3") (assoc 8 e) e)) ) ) (princ) ) Thank you, I tried your code but it simply doesn't work as I write the command -MTL- nothing happens and command line is ready for a new command ... if you could modify it then it would be great. thank you. by the way I can't appreciate your kindness ... Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 3, 2015 Share Posted March 3, 2015 Did you change the code in RED and Blue to match your dwg ? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 3, 2015 Share Posted March 3, 2015 Thank you. Thank you, I tried your code but it simply doesn't work as I write the command -MTL- nothing happens and command line is ready for a new command ... if you could modify it then it would be great. thank you. by the way I can't appreciate your kindness ... You are welcome You just changed the command name of the program and did not change the highlighted words that I indicated to . I doubt that you read the notes that I wrote earlier in the same post of the program Quote Link to comment Share on other sites More sharing options...
raptor22 Posted March 6, 2015 Author Share Posted March 6, 2015 You are welcome You just changed the command name of the program and did not change the highlighted words that I indicated to . I doubt that you read the notes that I wrote earlier in the same post of the program Hey there ... I am so sorry you are right my bad ... I did exactly what you said and it worked , thx again... but instead of inserting my blocks to the given layer name (06-Door) all of them got inserted into a layer by the name of "Layer3" which didn't exist before. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 6, 2015 Share Posted March 6, 2015 Try the following program, change the highlighted section to suit: ([color=BLUE]defun[/color] c:blklaymap ( [color=BLUE]/[/color] enx idx lay map sel ) ([color=BLUE]setq[/color] map '([highlight] ([color=MAROON]"Door"[/color] . [color=MAROON]"Door Layer"[/color]) ([color=MAROON]"Wall"[/color] . [color=MAROON]"Wall Layer"[/color])[/highlight] ) map ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cons[/color] ([color=BLUE]strcase[/color] ([color=BLUE]car[/color] x)) ([color=BLUE]cdr[/color] x))) map) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] ([color=BLUE]append[/color] '( ( 0 . [color=MAROON]"INSERT"[/color]) (-4 . [color=MAROON]"<OR"[/color]) ( 2 . [color=MAROON]"`*U*"[/color]) ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( x ) ([color=BLUE]cons[/color] 2 ([color=BLUE]car[/color] x))) map) '( (-4 . [color=MAROON]"OR>"[/color]) ) ) ) ) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] idx ([color=BLUE]sslength[/color] sel)) ([color=BLUE]setq[/color] enx ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] idx ([color=BLUE]1-[/color] idx))))) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] lay ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] ([color=BLUE]strcase[/color] (LM:name->effectivename ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 enx)))) map))) ([color=BLUE]entmod[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 8 lay) ([color=BLUE]assoc[/color] 8 enx) enx)) ) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; Block Name -> Effective Block Name - Lee Mac[/color] [color=GREEN];; blk - [str] Block name[/color] ([color=BLUE]defun[/color] LM:name->effectivename ( blk [color=BLUE]/[/color] rep ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]wcmatch[/color] blk [color=MAROON]"`**"[/color]) ([color=BLUE]setq[/color] rep ([color=BLUE]cdadr[/color] ([color=BLUE]assoc[/color] -3 ([color=BLUE]entget[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 330 ([color=BLUE]entget[/color] ([color=BLUE]tblobjname[/color] [color=MAROON]"block"[/color] blk)))) '([color=MAROON]"AcDbBlockRepBTag"[/color]) ) ) ) ) ([color=BLUE]setq[/color] rep ([color=BLUE]handent[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 1005 rep)))) ) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 2 ([color=BLUE]entget[/color] rep))) blk ) ) ([color=BLUE]princ[/color]) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 6, 2015 Share Posted March 6, 2015 Hey there ... I am so sorry you are right my bad ... I did exactly what you said and it worked , thx again... but instead of inserting my blocks to the given layer name (06-Door) all of them got inserted into a layer by the name of "Layer3" which didn't exist before. You are welcome . and happy you got it working . Quote Link to comment Share on other sites More sharing options...
raptor22 Posted March 13, 2015 Author Share Posted March 13, 2015 Try the following program, change the highlighted section to suit: Thx a million it worked ... exactly what I wanted ... You are welcome . and happy you got it working . Thank you .... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 13, 2015 Share Posted March 13, 2015 Thx a million it worked ... exactly what I wanted ... Excellent, you're welcome. 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.