Tripledot Posted July 26, 2016 Share Posted July 26, 2016 Is there a lisp that allow us to change an entity layer, in a nested block, to another predefined layer eg. defpoints. without entering the block. Been bogged down by continuously going in and out of the block editor /edit block in place, 50 odd times in 1 DWG just to change the layer of a few lines is exhausting. The work is already taking too Long as it is. Hoping for some help. Thanks. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2016 Share Posted July 26, 2016 Can you write down the steps of the program that you want the program to proceed with? Also can you list the name of the nested blocks and the target layer? Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 26, 2016 Author Share Posted July 26, 2016 (edited) Can you write down the steps of the program that you want the program to proceed with? Also can you list the name of the nested blocks and the target layer? Block A 1) Run lisp 2) from modelspace, select the :- X) entity/entities of a couple of lines/polylines/circle..... continuously (which is inside Block A) or Y) entity/entities of a couple of lines/polylines/circle..... continuously (which is inside Block B which is Inside A) & entity/entities of a couple of lines (inside Block C which is inside Block B which is inside Block A) * in both scenarios, X & Y, the selected entity/entities will be highlighted throughout the selection process regardless of which block the entitiy/entities it is from. (As I would not know the actually block name as it is too many & with long names & different depth levels) 3) After the selection, Press ENTER 4) Selected entity/entities in both scenario X & Y will then change to "DEFPOINTS" layer Target layer is DEFPOINTS. (But can change to other layer names within the lisp code) Hope this can help Tharwat Edited July 26, 2016 by Tripledot Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2016 Share Posted July 26, 2016 So you need to move lines objects in nested Blocks of the selected blocks to layer DefPoints ? Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 26, 2016 Author Share Posted July 26, 2016 So you need to move lines objects in nested Blocks of the selected blocks to layer DefPoints ? Yes, mainly the entities like lines,polylines,circle......that is within blocks or nested blocks. The layers of blocks/nested blocks remains untouch. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2016 Share Posted July 26, 2016 Yes, mainly the entities like lines,polylines,circle......that is within blocks or nested blocks. The layers of blocks/nested blocks remains untouch. How come is that ? Please specify your goal of the program very strictly and clearly. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 26, 2016 Author Share Posted July 26, 2016 How come is that ? Please specify your goal of the program very strictly and clearly. Block A Block A contains line 1,2 & 3 Currently what i am doing: 1) Using refedit, select the Block A of the lines i want to change layer. 2) Withing the block editor of Block A, select Line 1, line 2 & line 3 & change to defpoints layer 3) Saved & exit block editor 4) Using refedit, select the Block B of the lines i want to change layer. 5) Withing the block editor of Block B, select Line 4, line 5 & line 6 & change to defpoints layer 6) Saved & exit block editor 7) Using refedit, select the Block C of the lines i want to change layer. 8 ) Withing the block editor of Block C, select Line 7, line 8 & line 9 & change to defpoints layer 9) Saved & exit block editor What i like the Lisp to do is: 1) Run Lisp 2) Select line 1, 2, 3, 4, 5,6 ,7 ,8 & 9. 3) Enter. 4) Layer of line 1, 2, 3, 4, 5,6 ,7 ,8 & 9 change to Defpoints Quote Link to comment Share on other sites More sharing options...
ReMark Posted July 26, 2016 Share Posted July 26, 2016 Why would you be moving these entities to layer Defpoints? That layer really should be restricted to its intended use. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 26, 2016 Author Share Posted July 26, 2016 Why would you be moving these entities to layer Defpoints? That layer really should be restricted to its intended use. I need to convert the entity/entities to a separate layer,in which case, where my office have setup to have defpoints switch off so that selected entity/entities will not be seen. In actuality, not necessary defpoints but since office setup this way so I follow. Hence I also indicated that target layer can be change within the lisp code to offer me a flexibility. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 26, 2016 Share Posted July 26, 2016 Just for clarification: When you say nested block that means a block within a block(s) so I think in your case you are talking about regular block(s) correct? With lisp you can not select entities as you are selecting entities in a layout / Model space but this should be proceed by iterating through entities within the selected block(s) then change layers, colors, lineTypes ... etc. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 26, 2016 Author Share Posted July 26, 2016 Just for clarification:When you say nested block that means a block within a block(s) so I think in your case you are talking about regular block(s) correct? Yes. Regular nested blocks. With lisp you can not select entities as you are selecting entities in a layout / Model space but this should be proceed by iterating through entities within the selected block(s) then change layers, colors, lineTypes ... etc. Not sure what you mean. With lisp it is not possible? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 26, 2016 Share Posted July 26, 2016 Related topic/solution. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 27, 2016 Author Share Posted July 27, 2016 Related topic/solution. Good god. This is freaking awesome! (defun c:ddd ( / doc enm) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (while (setq enm (car (nentsel))) (vla-put-layer (vlax-ename->vla-object enm) "defpoints") (vla-regen doc acactiveviewport) ) (vla-regen doc acallviewports) (vla-endundomark doc) (princ) ) Could i trouble you to add the code in the lisp to allow for predefine Linetype & colour override. Thanks Roy_043 Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 27, 2016 Share Posted July 27, 2016 (defun c:ddd ( / doc enm obj) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (while (setq enm (car (nentsel))) (setq obj (vlax-ename->vla-object enm)) (vla-put-layer obj "Defpoints") ; Layer must exist. (vla-put-color obj 11) (vla-put-linetype obj "Hidden") ; Linetype must exist. (vla-regen doc acactiveviewport) ) (vla-regen doc acallviewports) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 27, 2016 Author Share Posted July 27, 2016 (defun c:ddd ( / doc enm obj) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (while (setq enm (car (nentsel))) (setq obj (vlax-ename->vla-object enm)) (vla-put-layer obj "Defpoints") ; Layer must exist. (vla-put-color obj 11) (vla-put-linetype obj "Hidden") ; Linetype must exist. (vla-regen doc acactiveviewport) ) (vla-regen doc acallviewports) (vla-endundomark doc) (princ) ) Got an error Command: ddd Select object: ; error: Automation Error. Key not found Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted July 27, 2016 Share Posted July 27, 2016 As I mentioned in the comments: the layer and the linetype must exist in the dwg. Most likely that is the cause of your error. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted July 27, 2016 Author Share Posted July 27, 2016 As I mentioned in the comments: the layer and the linetype must exist in the dwg. Most likely that is the cause of your error. Forgot about the linetype. . Working good now. Thanks Roy_043 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.