nickname1988 Posted May 24, 2009 Share Posted May 24, 2009 I have to do a program in lisp that Delete all circle that are rad Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 24, 2009 Share Posted May 24, 2009 Is this for an assignment of some sort? - as, if it is, I'd rather step you through it, than just post the answer Quote Link to comment Share on other sites More sharing options...
nickname1988 Posted May 24, 2009 Author Share Posted May 24, 2009 It it's for school...... yes it is some sort of assignement..... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 24, 2009 Share Posted May 24, 2009 This should give you a decent starting point - just "uncomment" the method you wish to use ; Function to Delete all Circles ; with Radius < 100. (defun c:DelCir (/ ss) ; Define function and localise variables. ; We use "defun c:" to declare that the ; function can be called from the command line. ; The function syntax in this case is "DelCir". (if ; If we can retrieve a Selection Set of Circles (setq ss ; Set the Selection Set to a variable "ss" (ssget "_X" ; Search Entire Database '((0 . "CIRCLE") ; Filter Circles (-4 . "<") ; Less than (40 . 100) ; 100 Radius ) ; End Filter List ) ; End ssget ) ; End setq ;; There are Many ways to do the next bit... here are a few: ;; Method 1: ;;; (foreach x ; for Every Entity in the following list ;;; ;;; (mapcar 'cadr ; Retrieve Entity Name ;;; ;;; (ssnamex ss) ; Retrieve Selection Set Information ;;; ;;; ) ; End mapcar ;;; ;;; (entdel x) ; Delete Entity ;;; ;;; ) ; End Foreach ;;; ;; Method 2: ;;; (command "_erase" ss "") ;; Method 3: ;;; (vl-load-com) ; Load VL functions ;;; ;;; (foreach x ; for Every Entity in the following list ;;; ;;; (mapcar 'vlax-ename->vla-object ; Convert Entity to VLA-object ;;; ;;; (mapcar 'cadr ; Retrieve Entity Name ;;; ;;; (ssnamex ss) ; Retrieve SelSet info ;;; ;;; ) ; end mapcar ;;; ;;; ) ; end mapcar ;;; ;;; (if ; If the following returns T ;;; ;;; (vl-catch-all-error-p ; If there is an error ;;; ;;; (vl-catch-all-apply ; Apply the following, and return any Errors ;;; ;;; 'vla-delete ; Delete function ;;; ;;; (list x) ; VLA-object ;;; ;;; ) ; end vl-catch-all-apply ;;; ;;; ) ; end vl-catch-all-error-p ;;; ;;; (princ "\nObject on Locked Layer!") ; if an Error Occurs, print this message ;;; ;;; ) ; End if ;;; ;;; ) ; end Foreach ;; --- End of Method 3 --- ) ; End Main IF statement (princ) ; Exit Cleanly ) ; End DelCir Quote Link to comment Share on other sites More sharing options...
nickname1988 Posted May 24, 2009 Author Share Posted May 24, 2009 wow tnx u .. ur a life saver:D Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 24, 2009 Share Posted May 24, 2009 wow tnx u .. ur a life saver:D No problem, btw, comments are anything after a semi-colon ( Also, Method 3 will deal 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.