Jump to content

Deleting selected texts on the list - Help


pavilon

Recommended Posts

I have a dcl and a lisp that list all text and mtext in a drawing and I want to delete selected texts on the list by Delete button on DCL but I need to resolve(if possible):

 

1) My first goal to delete multiple texts by selection does not work! I get an error of : error: bad argument type: consp nil

 

2) Overwriting duplicated texts or group similar texts

 

3) Sorting out text from A_Z , 0-9, etc.

 

4) how can stay in dialogue until I finish erasing desired texts? Now it closing dialogue(although delete not working properly)

 

attached is my lisp and dcl.

 

Thanks

deltext.dcl

DELTEXT.LSP

Link to comment
Share on other sites

I have not read your lisp file (yet) , things 2 do you know, but as for point 3 in your wishlist , I think you need to hide your dialog because erasing texts mean updating your display and that is forbidden when a dialog is active.

 

 

Gr. Rlx

Link to comment
Share on other sites

Just had a quick look during my break and your code stops at (nth item t_lst) because t_lst is nil.

 

 

Do you mean (nth item l) instead of t_lst ? ... as in (setq l (_list_texts))

 

 

gr.Rlx

Edited by rlx
Link to comment
Share on other sites

Ok , my boss is gonna kill me for not having this drawings ready yet ;-) but try this :

 


(vl-load-com)


;scan for string
(defun sfs ( %p1 %p2 / ss i enum etyp elist)
  (if (setq elist '() i 0 ss (ssget "c" %p1 %p2))
      (while (setq enum (ssname ss i))
          (setq etyp (cdr (assoc 0 (entget enum))))
          (if (member etyp '("TEXT" "MTEXT"))(setq elist (append elist (list enum))))
          (setq i (1+ i))))
   elist
)

(defun rdup ( i / o );remove duplicates
   (vl-remove-if '(lambda (x) (cond ((vl-position x o) t) ((setq o (cons x o)) nil))) i))

(defun rlx_deltxt ( / txt-ent-list stringlist ent)
   (setq txt-ent-list (sfs (getvar "extmin") (getvar "exmax")))
   (setq stringlist (rdup retlist))
   (foreach ent txt-ent-list
    (if (member (vla-get-textstring ent) stringlist) (entdel ent))))


your retlist can contain duplicates so i remove them first.

with sfs (scan for string) i scan the entire dwg for text / mtext

finaly i test each (m)text entity if it contains one of the selected strings and if it does it will be deleted.

 

 

I haven't tested it yet

 

 

gr. Rlx

Edited by rlx
Link to comment
Share on other sites

(if (= (start_dialog) 1)
(progn
(do_atn)
(unload_dialog dcl_id)
(princ "\nTexts Deleted ..:\n")
(princ  retlist)
(princ)
)
)

 

 

BTW , add just add my code to your lsp and replace (do_atn) at the end of your code with (rlx_deltxt)

 

gr. Rlx

Link to comment
Share on other sites

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...