ksperopoulos Posted June 20, 2010 Share Posted June 20, 2010 I am trying to delete all the dimensions in a drawing, but I am stuck on how to accomplish this. (defun C:edims () (command "erase"(ssget (list (cons 0 "DIMENSION"))) "all" "") (princ) ) Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 20, 2010 Author Share Posted June 20, 2010 I think I got it. At least it seems to work. (defun C:edims () (command "erase" (ssget "x" (list (cons 0 "DIMENSION"))) "" (princ) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 20, 2010 Share Posted June 20, 2010 I think I got it. At least it seems to work. (defun C:edims () (command "erase" (ssget "x" (list (cons 0 "DIMENSION"))) "" (princ) ) ) Hi. The following codes will run with no ; error: bad argument value: AutoCAD command as your codes are responding to command line, and you can check this out. (defun C:edims (/ er) (setq er(ssget "_x" (list (cons 0 "DIMENSION")))) (command "_erase" er "") (princ) ) Regards. Tharwar Quote Link to comment Share on other sites More sharing options...
VVA Posted June 20, 2010 Share Posted June 20, 2010 Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION (defun C:edims (/ ss) (if (setq ss (ssget "_x" (list (cons 0 "[b][color="Red"]*[/color][/b]DIMENSION")))) (command "_erase" ss "") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 20, 2010 Share Posted June 20, 2010 Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION (defun C:edims (/ ss) (if (setq ss (ssget "_x" (list (cons 0 "[b][color="Red"]*[/color][/b]DIMENSION")))) (command "_erase" ss "") ) (princ) ) Hi I wonder what is the use of that astrisk. Best Regards Tharwat Quote Link to comment Share on other sites More sharing options...
CHLUCFENG Posted June 20, 2010 Share Posted June 20, 2010 The asterisk (*) means wildcard for any number of charachters prior to the word dimension. I use it often to freeze furniture layers in an architectural drawing. For example, type at command line: (command "layer" "F" "*furn*" "") all layers containing the letters 'furn' consecutively (in that order) will be frozen. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 20, 2010 Share Posted June 20, 2010 The asterisk (*) means wildcard for any number of charachters prior to the word dimension. I use it often to freeze furniture layers in an architectural drawing. For example, type at command line: (command "layer" "F" "*furn*" "") all layers containing the letters 'furn' consecutively (in that order) will be frozen. Thanks for your explanations... but I tried also the following it worked as well as yours. (command "layer" "F" "furn" "") So what is the difference between both of them Please. Regards Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 20, 2010 Share Posted June 20, 2010 Look up wcmatch in the help file. Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 20, 2010 Author Share Posted June 20, 2010 Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION [/quote] Good point! I have a pretty basic lisp question for a beginner though....what is the purpose for the (/ ss) after the function's name and do I need it if I am going to simply add the process of this lisp to another lisp as opposed to running it as its own command? Hope that makes sense. Quote Link to comment Share on other sites More sharing options...
VVA Posted June 20, 2010 Share Posted June 20, 2010 names after / - local variables. The time of their lives - body functions (commands) to which they are defined small example (defun C:TEST1 ( ) ;;;str - a global variable. It retains its value after the command (setq str (getstring "\nType any word: ")) (princ "\nYou enter ")(princ str) (princ) ) (defun C:TEST2 (/ str1 ) ;;;str1 - a local variable. It is removed after the completion of command (setq str1 (getstring "\nType any word: ")) (princ "\nYou enter ")(princ str1) (princ) ) And Result Command: test1 Type any word: TEST You enter TEST Command: Command: !str "TEST" Command: test2 Type any word: TEST You enter TEST Command: Command: !str1 nil Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 20, 2010 Share Posted June 20, 2010 An old FAQ I wrote a while back... http://www.cadtutor.net/forum/showpost.php?p=265649&postcount=4 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 20, 2010 Share Posted June 20, 2010 names after / - local variables. The time of their lives - body functions (commands) to which they are definedsmall example (defun C:TEST1 ( ) ;;;str - a global variable. It retains its value after the command (setq str (getstring "\nType any word: ")) (princ "\nYou enter ")(princ str) (princ) ) (defun C:TEST2 (/ str1 ) ;;;str1 - a local variable. It is removed after the completion of command (setq str1 (getstring "\nType any word: ")) (princ "\nYou enter ")(princ str1) (princ) ) And Result really nice explanation , And I haven't known that way before. But what about this function (defun abc (o p q r / v w x y z) Does it mean that they have to be supported with values before implementing the defun function Thanks Tharwat Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted June 20, 2010 Author Share Posted June 20, 2010 Thanks for the explanation VVA. So these would be needed if I were to include them in another lisp without the defun name to carry the variable through that command. Quote Link to comment Share on other sites More sharing options...
Guest jjorozco Posted June 20, 2012 Share Posted June 20, 2012 The code does not work on paper view Quote Link to comment Share on other sites More sharing options...
pBe Posted June 21, 2012 Share Posted June 21, 2012 Because it invokes a call to command function. it only "erase" objects on the current layout. Quick mod: (defun C:edims (/ ss) (if (setq ss (ssget "_x" (list (cons 0 "*DIMENSION")))) (repeat (sslength ss) (entdel (ssname ss 0)) (ssdel (ssname ss 0) ss)) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 21, 2012 Share Posted June 21, 2012 Another: (defun c:deldims ( / d ) (vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object)))) (if (eq :vlax-false (vla-get-isxref b)) (vlax-for o b (if (wcmatch (vla-get-objectname o) "AcDb*Dimension*") (vl-catch-all-apply 'vla-delete (list o)) ) ) ) ) (vla-regen d acallviewports) (princ) ) (vl-load-com) (princ) Will delete all Dimension types found in all layouts and in all blocks and nested blocks. Will omit Dimensions in XRefs and on locked layers. Quote Link to comment Share on other sites More sharing options...
pBe Posted June 21, 2012 Share Posted June 21, 2012 (vl-catch-all-apply 'vla-delete (list o)) .....and on locked layers. Clever, I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 21, 2012 Share Posted June 21, 2012 I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ? entdel / entmod will still fail to delete / modify entities on locked layers, however, when these functions fail they return nil rather than error. When Visual LISP functions fail, they cause an exception to occur. Compare the behaviour of: AutoLISP Visual LISP ------------------------------------------ entdel vla-delete entmod vlax-put-property tblsearch / dictsearch vla-item etc. Quote Link to comment Share on other sites More sharing options...
pBe Posted June 21, 2012 Share Posted June 21, 2012 ....rather than error. When Visual LISP functions fail, they cause an exception to occur. Got it. Thanks Lee Cheers Quote Link to comment Share on other sites More sharing options...
Guest jjorozco Posted June 22, 2012 Share Posted June 22, 2012 You can apply it with locked layers? 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.