- (DEFUN c:test (/) (IF (SETQ s (SSGET '((0 . "TEXT") (8 . "CB_Richiami")))) (PROGN (SETQ i 0 n (SSLENGTH s) ) (WHILE (< i n) (IF (= (SUBSTR (CDR (ASSOC 1 (ENTGET (SSNAME s i)))) 1 2) "1%") (PROGN (SETQ e (SSNAME s i) testo_originale (SUBSTR (CDR (ASSOC 1 (ENTGET (SSNAME s i)))) 2 20 ) x_data (CDR (CADR (CAR (CDR (ASSOC -3 (ENTGET e '("*"))))))) ) (conta_barre x_data);;; (SETQ vobject (VLAX-ENAME->VLA-OBJECT e));;; (SETQ text (VLA-GET-TEXTSTRING vobject));;; (VLA-PUT-TEXTSTRING vobject "New text string") (setq testo_modificato (strcat (itoa n_ferri) testo_originale )) (entmod (SUBST (CONS 1 testo_modificato) (ASSOC 1 (entget e)) (entget e))) ) ) (SETQ i (1+ i)) ) ) ))(defun conta_barre (x / i n freccie x_data x e) (if (setq freccie (ssget "_A" '((0 . "INSERT") (8 . "CB_Richiami")))) (progn (setq i 0 n_ferri -1 n (sslength freccie) ) (while (< i n) (setq e (ssname freccie i) x_data (cdr (cadr (car (cdr (assoc -3 (entget e '("*"))))))) i (1+ i) ) (IF (= x_data x) (setq n_ferri (1+ n_ferri)) ) ) ) ) )
It's related to another post you've answered...
http://www.cadtutor.net/forum/showthread.php?97959-Find-where-are-stored-information-about-an-entity/page4
Instead of create the quote (wasn't able to identify the number of the bar) I want only to correct in a brutal way the number in front of the text.
I've discovered that ARROWS have the same XDATA of the text I want to modify.
The idea for the new code is to:
1. get a selection set of all these arrows
2. using your code (THANKS!) to create a list with (XDATA . N°_ITEMS)
3. search TEXT with 1st, 2nd, etc, element of xdata from your code
4. entmod it with the correct number
This is what I've write until now:
- (defun C:test (/) (if (setq s (ssget '((0 . "INSERT") (8 . "CB_Richiami") (2 . "aca_freccia")))) (progn (setq i 0 n (sslength s) lista nil ) (while (< i n) (progn (setq e (ssname s i) x (cdr (cadr (car (cdr (assoc -3 (entget e '("*"))))))) i (1+ i) ) (setq lista (append (list x) lista)) ;;; (setq testo_modificato (strcat (itoa n_ferri) testo_originale ));;; (entmod (SUBST (CONS 1 testo_modificato) (ASSOC 1 (entget e)) (entget e))) ) );end while(setq lst (LM:CountItems lista)) ) )(mod_elementi) )(defun LM:CountItems ( l / c x ) (if (setq x (car l)) (progn (setq c (length l) l (vl-remove x (cdr l)) ) (cons (cons x (- c (length l))) (LM:CountItems l)) ) ))(defun mod_elementi (/) (IF (setq s (ssget "_A" '((0 . "TEXT") (8 . "CB_Richiami")))) (progn (setq i 0 n (sslength s) ) (while (< i n) (progn (IF (/= (substr (cdr (assoc 1 (entget (ssname s i)))) 1 2) "1%") (progn (setq x (car s)) (vl-remove x (cdr s)) (setq n (1- n)) ) ) (setq i (1+ i)) ) ) ) ) )
I'm stacked with the point 3..
Anyway the point 4 (entmod) create some problems.. a lot of items generated with the program I use get messed. I don't know why..
If I ssget little portions of drawing that doesn't happen. FIXED