乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 72|回复: 4

[编程交流] ssget: add a filter for xdata

[复制链接]

44

主题

139

帖子

95

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
221
发表于 2022-7-5 17:03:17 | 显示全部楼层 |阅读模式
Hello! A tittle question...
Is it possible to make a ssget with XDATA values?
 
  1. (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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:33:12 | 显示全部楼层
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.
回复

使用道具 举报

44

主题

139

帖子

95

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
221
发表于 2022-7-5 17:35:18 | 显示全部楼层
Thanks for the reply Mr. Lee!
 
Yeah, as i thought I need to process that list..
 
  1. (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!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:57:38 | 显示全部楼层
What are you trying to modify Dennis?
回复

使用道具 举报

44

主题

139

帖子

95

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
221
发表于 2022-7-5 18:15:02 | 显示全部楼层
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:
  1. (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:
  1. (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
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 02:11 , Processed in 4.777378 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表