List all text within a drawing

List all text within a drawing

Anonymous
Not applicable
2,589 Views
8 Replies
Message 1 of 9

List all text within a drawing

Anonymous
Not applicable

I have a DCL that try to populate a list box into it which will show all text within that drawing.

 

:column {
:list_box {
label="Text List";
key="text_list";

I have a lisp for layer listing but how can I list texts (Text and Mtext)?

 

Thanks 

0 Likes
2,590 Views
8 Replies
Replies (8)
Message 2 of 9

_Tharwat
Advisor
Advisor

Try this UNTESTED codes.

 

(defun _list_Texts (/ ss l)
  (if (setq ss (ssget "_X" '((0 . "TEXT,MTEXT"))))
    ((lambda (i / sn)
       (while (setq sn (ssname ss (setq i (1+ i))))
         (setq l (cons (cdr (assoc 1 (entget sn))) l))
       )
     )
      -1
    )
  )
  l
)

(if (setq l (_list_Texts))
  (progn
    (start_list "text_list")
    (mapcar 'add_list l)
    (end_list)
  )
)
0 Likes
Message 3 of 9

sam_safinia
Advocate
Advocate

Hi _Tharwat.

It doesn't work. I have attached dcl and lisp file for anyone review

0 Likes
Message 4 of 9

_Tharwat
Advisor
Advisor

You did not place the related codes that feeds the list_box in the correct place into your routine , anyway here is the first part modified as per your lisp codes.

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Text List <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
(defun _list_texts (/ ss l)
  (if (setq ss (ssget "_X" '((0 . "TEXT,MTEXT"))))
    ((lambda (i / sn)
       (while (setq sn (ssname ss (setq i (1+ i))))
         (setq l (cons (cdr (assoc 1 (entget sn))) l))
         )
       )
      -1
      )
    )
  l
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main Body <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

(defun c:deltext (/ txtlst xx txt t_lst dcl_id readlist retlist cnt l_en
                  l_name sent l
                  )


  (setvar "cmdecho" 0)

  (setq dcl_id (load_dialog "deltext.dcl"))

  (if (not (new_dialog "deltext" dcl_id))
    (exit)
    )

(if (setq l (_list_texts))
  (progn
    (start_list "txt_list")
    (mapcar 'add_list l)
    (end_list)
    )
  )
............
...............
......................
..........................
0 Likes
Message 5 of 9

Anonymous
Not applicable

here

0 Likes
Message 6 of 9

sam_safinia
Advocate
Advocate

_Tharwat: Just test your modified code today and it could all text to the list.

 

I'll appreciated any help to resolve:

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

 

 

2) Overwriting duplicated texts

 

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

 

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

0 Likes
Message 7 of 9

sam_safinia
Advocate
Advocate
Any help? Please
0 Likes
Message 8 of 9

_Tharwat
Advisor
Advisor

@s_plant wrote:
Any help? Please

Are you the owner of this thread ? do you have two accounts in this forum ?

0 Likes
Message 9 of 9

Anonymous
Not applicable

Sorry for confusing. I am the owner . I didn't mean to have two accounts but I was not aware of until I logged in from my old PC and post a thread then realized it's my old account. It is frustrating for me to keep track of them. I tried to merge my old posts into my new account but no success. My best option is to retire the old one. Sorry if it make confusing but at the end of the day I learnt heaps from both. Thanks

0 Likes