Jump to content

Recommended Posts

Posted

Hoping the title isn't too confusing..

 

I wonder if anyone has anything that can do this handy that they can share?

 

I have wiring diagrams, and at each end of the wire is the reference to it (lets call them C-1, C-2, P-1, P-2 and so on with a few different formats depending on the wire type and function in each drawing).

So there should be for example 2x C-1, 2x C-2 and so on

 

What I am looking for is a dead simple routine that will grab all the text strings in the drawing, and list them in the command line for example as C-1: 2, C-2: 2 as a check that I have got both ends accounted for and also so that if say P-1: 4 - I can spot there is a problem. It doesn't matter if it picks up drawing titles, notes, equipment names, so I guess if it gets all the text and lists how many times it occurs in the drawing that would be great. (I've seen routines or can use find / replace to count individual text, but that's not quite what I want to do)

 

 

If not I'll add it to my list of things to think about in the future.

 


Thanks in advance.

Posted

Is the text string at either end the same? Are there any layers containing text that can be eliminated?

 

Posted

Yes the text string should be the same at either end, thanks (but this is what I want to check.. if the text string count = 1 (or 3, 4....) then I have missed it somewhere)

 

I wasn't wanting to complicate things too much with eliminating layers, I can turn on or off layers to suit for now

 

Thanks for your reply

Posted

Try this, minimally tested. If you need to exclude a layer then freeze it as opposed to off, otherwise the ssget will still pick it up.

 

(defun c:txtcnt ( / ss cnt t_lst tot txt r_lst)
  (setq ss (ssget "_A" '((0 . "TEXT"))))
  (cond (ss
          (repeat (setq cnt (sslength ss))
            (setq t_lst (cons (cdr (assoc 1 (entget (ssname ss (setq cnt (1- cnt)))))) t_lst))
          );end repeat
          (while (> (length t_lst) 1)
            (setq tot 1
                  txt (car t_lst)
                  t_lst (cdr t_lst)
            );end_setq
            (foreach x t_lst (if (= x txt) (setq tot (1+ tot))))
            (setq r_lst (cons (list txt tot) r_lst))
            (setq t_lst (vl-remove-if '(lambda (x) (= x txt)) t_lst))
          );end_while
          (if (= (length t_lst) 1) (setq r_lst (cons (list (car t_lst) 1) r_lst)))
          (mapcar '(lambda (x) (cond ( (/= (cadr x) 2) (princ (strcat "\n" (car x) " : " (itoa (cadr x))))))) r_lst)
        )
  );end_cond
  (princ)
);end_defun

 

Posted

Thanks - I think it is mostly working, doesn't appear to be getting all the text on my test drawing so this afternoon I will look at it - I suspect it is my drawing rather than the code

 

I've added a '*' to the ssget text - the test drawing has mtext in there also

Posted
6 minutes ago, Steven P said:

Thanks - I think it is mostly working, doesn't appear to be getting all the text on my test drawing so this afternoon I will look at it - I suspect it is my drawing rather than the code

 

I've added a '*' to the ssget text - the test drawing has mtext in there also

 

The * to the text should be OK provided the MText is not formatted, otherwise it will fail as the format string forms part of the text string.

Posted

Maybe a  sort on a list (c-1)(p-1)(c-2 ) would make life easier for counting.

Posted

Thanks BigAl, I was hoping to avoid making a list of numbers to count, though I can see how I could make that work.

 

 

I can't have been well yesterday, I forgot to check Lee Macs website - text counter looks almost what I was looking for as a check, though it looks like it also counts mtext with different formats as different text strings (not a problem, the wire numbers should really be normal text).

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