明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1619|回复: 8

[基础] SSGET的返回值

[复制链接]
发表于 2009-10-21 15:37:00 | 显示全部楼层 |阅读模式

(setq ss (ssget))

(alert ss)

 

这个思路如何实现

比如我选择了图号:0825C-5-10-2001/2002-PL-ST-02/01,如何让他显示出来!或者赋值!

 

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2009-10-21 15:57:00 | 显示全部楼层

如果你只选一个文字的话

(setq a (entget (ssname (ssget) 0)))
(setq b (cdr (assoc 1 a)))
(alert b)

一句话  (alert (cdr (assoc 1 (entget (ssname (ssget) 0))  )))  也可以

 楼主| 发表于 2009-10-21 16:33:00 | 显示全部楼层

秋枫批量打印3.3.8

phoenixdjq发表于2009-10-21 15:57:00如果你只选一个文字的话(setq a (entget (ssname (ssget) 0)))(setq b (cdr (assoc 1 a)))(alert b)一句话  (alert (cdr (assoc 1 (entget (ssname (ssget) 0))  )))  也可以

那如果是多个文字怎么处理呢

发表于 2009-10-21 19:58:00 | 显示全部楼层
循环逐个处理。
发表于 2009-10-22 08:54:00 | 显示全部楼层

如果一个一个选择的话,还是使用entsel比较方便些

发表于 2009-10-22 11:59:00 | 显示全部楼层

做个循环是最重要的,楼主看看关于“循环”方面的教材吧

 楼主| 发表于 2009-10-22 16:59:00 | 显示全部楼层
phoenixdjq发表于2009-10-22 11:59:00做个循环是最重要的,楼主看看关于“循环”方面的教材吧

找的半天,没有发现相关材料,能给个链接吗?用死办法写了一个:

(defun c:1()
(setq ss (ssget))
(setq sl (sslength ss))

(setq a1 (cdr (assoc 1 (entget (ssname ss 0)))))

(if (= sl 1) (alert a1))   
                                                      
(if (= sl 2) (alert (setq a2 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1))))))))

(if (= sl 3) (alert (setq a3 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2))))))))
(if (= sl 4) (alert (setq a4 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3))))))))
(if (= sl 5) (alert (setq a5 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4))))))))
(if (= sl 6) (alert (setq a6 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5))))))))
(if (= sl 7) (alert (setq a7 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6))))))))
(if (= sl 8) (alert (setq a8 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7))))))))
(if (= sl 9) (alert (setq a9(STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7)))) "," (cdr (assoc 1 (entget (ssname ss 8))))))))
(if (= sl 10) (alert (setq a10(STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7)))) "," (cdr (assoc 1 (entget (ssname ss 8)))) "," (cdr (assoc 1 (entget (ssname ss 9))))))))

)

 

 

 

发表于 2009-10-22 18:09:00 | 显示全部楼层
;;選擇與順序有關
(defun C:TT (/ N SS STR)
  (setq SS  (ssget '((0 . "text")))
 N   0
 STR ""
  )
  (repeat (sslength SS)
    (setq STR (strcat STR (cdr (assoc 1 (entget (ssname SS N)))) "\n"))
    (setq N (1+ N))
  )
  (alert STR)
  (princ)
)
发表于 2009-10-23 08:54:00 | 显示全部楼层

本论坛有好多这样的书籍呀,像铁道部的<AUTOLISP&DCL>就很好,我就是从本论坛上下载的

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-6 10:01 , Processed in 0.178342 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表