Hi,
I have many blocks in drawings file. Few blocks are combine with polygon with text.
please guide me how to delete the text and mtext inside the blocks using lisp.
Regards
Try this .
(defun c:Deltext(/ ss i sn name blockdefinition namelist) ;;; Tharwat 24. Mar. 2014 ;;; (cond (doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) ) (princ "\n Select Blocks to remove texts within ... ") (if (setq ss (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (if (not (member (setq name (cdr (assoc 2 (entget sn)))) namelist)) (progn (setq namelist (cons name namelist)) (vlax-for x (setq blockdefinition (vla-item (vla-get-blocks doc) name)) (if (and (eq :vlax-false (vla-get-isxref blockdefinition)) (eq :vlax-false (vla-get-islayout blockdefinition)) (wcmatch (vla-get-objectname x) "AcDb*Text") ) (if (vlax-write-enabled-p x) (vla-delete x)) ) ) ) ) ) (princ) ) (if ss (vla-regen doc acAllViewports) ) (princ) ) (vl-load-com)
Thanks for sending lisp.
but that lisp not working in autocad2004. Is it working in higher version?
Regards
Sudarsan
Hi Tharwat,
I usually don't declare as a global a variable as "doc", because there may be another one with the same name, but it's only my opinion.
Your code is failing because the variable "doc", if don't exist in the document, the cond function will set the "doc" variable only if already exists, because the conditional function is the variable existence, not the non-existence...
Henrique
@hmsilva wrote:Hi Tharwat,
I usually don't declare as a global a variable as "doc", because there may be another one with the same name, but it's only my opinion.
Your code is failing because the variable "doc", if don't exist in the document, the cond function will set the "doc" variable only if already exists, because the conditional function is the variable existence, not the non-existence...Henrique
OMG , I have forgotten to add the two brackets before and after the variable in the cond function .
That is the result of not testing codes before posting sometimes .
Thank you Henrique for the correction .
(cond (doc) ((setq doc (vla-get-activedocument (vlax-get-acad-object)))) )
You're welcome, Tarwat.
But I would use a different condition,
(cond ((not doc) (setq doc (vla-get-activedocument (vlax-get-acad-object)))) )
The (doc) is testing a function...
Henrique
@hmsilva wrote:But I would use a different condition,
(cond ((not doc) (setq doc (vla-get-activedocument (vlax-get-acad-object)))) )The (doc) is testing a function...
Henrique
If you would go that way , then use IF function instead
For me I got used to call it the folloing way and I don't know why did I make it that way !
(or doc (setq doc .......
Hello,
I am new here on the forum, So is dont know if i am on the right place now.
I see that here is a lisp For deleting all text inside a block.
I need to have somthing similair. I need to find Mtext inside a lot of blocks en convert them to text. I dont want to explode the blocks
Is there a way to do this
nick