Jump to content

Recommended Posts

Posted

I have to do a program in lisp that Delete all circle that are rad

Posted

Is this for an assignment of some sort? - as, if it is, I'd rather step you through it, than just post the answer :)

Posted

It it's for school...... yes it is some sort of assignement.....

Posted

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

Posted

wow tnx u .. ur a life saver:D

Posted
wow tnx u .. ur a life saver:D

 

No problem, btw, comments are anything after a semi-colon (;) :D Also, Method 3 will deal with Locked Layers.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...