TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on December 19, 2007, 10:06:01 AM

Title: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: TJAM51 on December 19, 2007, 10:06:01 AM
This topic is two fold.
 
1. I have the following lisp routines in one file.

Code: [Select]
(defun c:deldim (/ ss)
  (setq ss (ssget "x" (list (cons 0 "Dimension"))))
  (if ss
    (command ".erase" ss "")
    (princ "\nNo dimensions in this drawing!")
  )
  (princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:dellead (/ ss)
  (setq ss (ssget "x" (list (cons 0 "LEADER"))))
  (if ss
    (command ".erase" ss "")
    (princ "\nNo leaders in this drawing!")
  )
  (princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:delmtext (/ ss)
  (setq ss (ssget "x" (list (cons 0 "mtext"))))
  (if ss
    (command ".erase" ss "")
    (princ "\nNo text in this drawing!")
  )
  (princ)
)




I would like to have one command to run them in sequence.

2. I have discovered blocks with the names starting with A$. Some will purge and some will not. I would like to be able to rename them and the naming convention is not important. Is there a way to have a lisp rename them with some convention that could drop the dollar sign and maybe leaving the remaining characters.

Thanks

<edit: added code tags- CAB>
Title: Re: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: ronjonp on December 19, 2007, 10:45:56 AM
Here is something to delete all at once.....*edit* will NOT bonk out if objects are on a locked layer:

Code: [Select]
(defun c:delstuff (/ ss)
  (if (setq ss (ssget "x" '((0 . "DIMENSION,LEADER,MTEXT"))))
    (mapcar
      '(lambda (x)
(if (not (equal (vla-get-lock
   (vlax-ename->vla-object
     (tblobjname "layer" (vla-get-layer x))
   )
)
:vlax-true
  )
     )
   (vla-delete x)
)
       )
      (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss)))
    )
  )
  (princ)
)
Title: Re: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: TJAM51 on December 19, 2007, 10:50:51 AM
Hey thanks a lot..
Title: Re: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: TJAM51 on December 19, 2007, 10:52:36 AM
Recieved the following error....


error: bad argument type: numberp: nil
Title: Re: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: TJAM51 on December 19, 2007, 10:53:41 AM
never mind....when I cut and paste I left off one of the ( :lol:
Title: Re: Loading small lisp within a larger lisp file - purge block A$SCO____
Post by: ronjonp on December 19, 2007, 11:04:34 AM
Hey thanks a lot..

Glad to help...I edited the code above to ignore items on locked layers.