LISP2LEARN Posted June 7, 2011 Share Posted June 7, 2011 What 'em I doing wrong here? I have several entities on the sketch layer and after sketching I want to delete that layer and all entities under it. I want to use the "laydel" command but I can't suppress the dialog box. I know that I can't delete a layer if it has entities referencing it. Can you point me out on the right direction. Thanks (vl-load-com) (setq MYLAYERS (vla-get-activedocument (vlax-get-acad-object))) (vla-delete (vla-get-layers MYLAYERS) "A-Sketch") Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 7, 2011 Share Posted June 7, 2011 I still find plain autolisp much more elegant and simple : (if (setq ss (ssget "X" '((8 . "A-Sketch"))) (command "_.ERASE" ss "")) Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted June 7, 2011 Share Posted June 7, 2011 I want to use the "laydel" command but I can't suppress the dialog box. Have you tried this? (vl-cmdf "-laydel" "_N" "A-BLDG" "" "_Y") ;;; replace "A-BLDG" with the layer name you want to delete Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 7, 2011 Author Share Posted June 7, 2011 thanks David, Yes, this erase all entities under the A-Sketch layer but still, it doesn't delete the attributes on the blocks which are on this layer and doesn't delete the layer itself. I have some blocks with attributes and the attributes are on the A-Sketch also but not the block which is on a different layer. I want to delete those attributes also under the block but not the block. I still find plain autolisp much more elegant and simple : (if (setq ss (ssget "X" '((8 . "A-Sketch"))) (command "_.ERASE" ss "")) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 7, 2011 Share Posted June 7, 2011 thanks David, I have some blocks with attributes and the attributes are on the A-Sketch also but not the block which is on a different layer. I want to delete those attributes also under the block but not the block. Now that sounds dangerous... -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2011 Share Posted June 7, 2011 If nothing is referencing your layer (including objects in blocks etc.), then this demonstrates how to delete the layer from the layer collection (assuming the layer exists): (setq LayerCollection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) LayerItem (vla-item LayerCollection [color=red]"YourLayerName"[/color]) ) (vla-delete LayerItem) Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks David & rkmcswain, The answer is right in front of me. Didn't know about "_(user input)" which suppress the dialog box. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted June 7, 2011 Share Posted June 7, 2011 Thanks David & rkmcswain, The answer is right in front of me. Didn't know about "_(user input)" which suppress the dialog box. As you probably know by now, LAYDEL will delete entities on the selected layer and redefine blocks, deleting entities on that layer. Another similar, less dangerous route would be to use LAYMRG and merge all of the unwanted layers to a new layer that you can review later. Just a thought. Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks Lee, very informative. I'm always impress on how you squeeze your code. I guess, I can do that too. Here it goes.. (Setq thanks "tnx li, ur da besttttttttttttttttttttttttttttt") (setq tnx (vl-string-right-trim "ttttttttttttttttttttttttttt " thanks)) (princ (strcat (tnx "LOL")) Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks for the concern, I'm fairly knowledgeable with autocad commands but not with lisp and now, I'm trying to write simple code to make my autocad life much simpler. Thanks rkmcswain, I owe you one. As you probably know by now, LAYDEL will delete entities on the selected layer and redefine blocks, deleting entities on that layer.Another similar, less dangerous route would be to use LAYMRG and merge all of the unwanted layers to a new layer that you can review later. Just a thought. Quote Link to comment Share on other sites More sharing options...
LISP2LEARN Posted June 7, 2011 Author Share Posted June 7, 2011 Thanks for the concern, I'm fairly knowledgeable with almost all autocad commands but not with lisp and now, I'm trying to write simple code to make my autocad life much simpler. Thanks rkmcswain, I owe you one. As you probably know by now, LAYDEL will delete entities on the selected layer and redefine blocks, deleting entities on that layer.Another similar, less dangerous route would be to use LAYMRG and merge all of the unwanted layers to a new layer that you can review later. Just a thought. Quote Link to comment Share on other sites More sharing options...
VVA Posted June 7, 2011 Share Posted June 7, 2011 My 5 cents. Turn off and / or freeze the layers you want to delete. Executing BGLAYDEL. Link (translate with google) 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.