ssget: add a filter for xdata
Hello! A tittle question...Is it possible to make a ssget with XDATA values?
(ssget "_A" '((0 . "TEXT") (8 . "CB_Richiami") (-3 ("_XDATA" (1000 . "196") (1000 . "196"))) ))
That code returns always nil (
Maybe the only solution is the selection set processing..
Thanks for your help!
Dennis Unfortunately you can only filter to the level of the application name (see here); you will therefore need to perform the additional filtering by testing each entity when processing the selection set. Thanks for the reply Mr. Lee!
Yeah, as i thought I need to process that list..
(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)) ) ) ) ) )
(setq x (car s)) this requires a list.. I need to convert the selection set to a list before.. anyway it's the right way?
Thanks! What are you trying to modify Dennis? This is a little part of a more complex bug fix of a program I use.
I've done the fix in another way but it's very inefficient so I started to rewrite the lisp.
This is the old code:
(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
页:
[1]