乐筑天下

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

[编程交流] L中的对象选择问题

[复制链接]

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 17:07:52 | 显示全部楼层 |阅读模式
我成功地编写了这段代码,它允许我更改对象的注释比例(AnnotationScale)。
 
当前问题:
-LISP使用“box”选择,这使我能够手动选择对象。我需要LISP来选择此时可见的所有对象。
我已经试过了(ssget“_A”),但这也会选择具有注释比例(AnnotationScale)的不可见对象。我需要它只选择当前活动annotationscale的所有对象。
 
而且
-LISP需要选择1:1的比例,然后才能继续进行1:2的翻译。如果没有annoscale为1:1的对象,我如何让LISP继续?有点像“没有那么大比例的物体”。然后继续。。。
 
希望有人能帮忙!
 
  1. (defun c:OBJECTSCHALENVERVANGEN ()
  2. (command "UNDO" "begin")
  3. (setvar 'annoallvisible 0)
  4. (command "_SchalenMaken" "ME")
  5. (SCHALEN1NEW)
  6. (SCHALEN2NEW)
  7. (command "CANNOSCALE" "NLCS_M_1:2")
  8. (command "undo" "end")
  9. )
  10. (defun SCHALEN1NEW ( / cmd ent idx lst scl sel )
  11.    (command "CANNOSCALE" "NLCS_M_1:1")
  12.    (cond
  13.        (   (= 1 (getvar 'cvport))
  14.            (princ "\nThis command is only available in Modelspace.")
  15.        )
  16.        (
  17.           (setq scl (getvar 'cannoscale)
  18.            )
  19.            (command "CANNOSCALE" "HB 1:1")
  20.            (setq sel (ssget "_:L" '((0 . "*TEXT,*DIMENSION,INSERT,HATCH,MULTILEADER"))))
  21.            (repeat (setq idx (sslength sel))
  22.                (if (setq ent (ssname sel (setq idx (1- idx)))
  23.                          lst (LM:annoscales ent)
  24.                    )
  25.                    (progn
  26.                        (if (not (member scl lst))
  27.                            (command "_.-objectscale" ent "" "_a" "NLCS_M_1:1" "")
  28.                        )
  29.                       (if (not (member scl lst))
  30.                            (command "_.-objectscale" ent "" "_d" "HB 1:1" "")
  31.                        )
  32.                    )
  33.                )
  34.            )
  35.        (command "CANNOSCALE" "NLCS_M_1:1")
  36.        )
  37.    )
  38.    (princ)
  39. )
  40. (defun SCHALEN2NEW ( / cmd ent idx lst scl sel )
  41.    (command "CANNOSCALE" "NLCS_M_1:2")
  42.    (cond
  43.        (   (= 1 (getvar 'cvport))
  44.            (princ "\nThis command is only available in Modelspace.")
  45.        )
  46.        (
  47.           (setq scl (getvar 'cannoscale)
  48.            )
  49.            (command "CANNOSCALE" "HB 1:2")
  50.            (setq sel (ssget "_:L" '((0 . "*TEXT,*DIMENSION,INSERT,HATCH,MULTILEADER"))))
  51.            (repeat (setq idx (sslength sel))
  52.                (if (setq ent (ssname sel (setq idx (1- idx)))
  53.                          lst (LM:annoscales ent)
  54.                    )
  55.                    (progn
  56.                        (if (not (member scl lst))
  57.                            (command "_.-objectscale" ent "" "_a" "NLCS_M_1:2" "")
  58.                        )
  59.                       (if (not (member scl lst))
  60.                            (command "_.-objectscale" ent "" "_d" "HB 1:2" "")
  61.                        )
  62.                    )
  63.                )
  64.            )
  65.        (command "CANNOSCALE" "NLCS_M_1:2")
  66.        )
  67.    )
  68.    (princ)
  69. )
  70. ;; Returns a list of all annotative scales associated with a supplied entity
  71. (defun LM:annoscales ( ent / dic enx itm rtn )
  72.    (if
  73.        (and
  74.            (setq enx (entget ent))
  75.            (setq dic (cdr (assoc 360 (cdr (member '(102 . "{ACAD_XDICTIONARY") enx)))))
  76.            (setq dic (cdr (assoc -1  (dictsearch dic "acdbcontextdatamanager"))))
  77.            (setq dic (cdr (assoc -1  (dictsearch dic "acdb_annotationscales"))))
  78.        )
  79.        (while (setq itm (dictnext dic (not itm)))
  80.            (setq rtn (cons (cdr (assoc 300 (entget (cdr (assoc 340 itm))))) rtn))
  81.        )
  82.    )
  83.    (reverse rtn)
  84. )
  85. (princ)
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 17:37:50 | 显示全部楼层
解决了它。:-)
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 18:07:07 | 显示全部楼层
如果你能分享你的解决方案,让其他人也能从中受益,那就太好了。
回复

使用道具 举报

76

主题

312

帖子

254

银币

后起之秀

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

铜币
390
发表于 2022-7-5 18:16:19 | 显示全部楼层
我用肮脏的方式解决了这个问题。但它做了必须做的事情。:-)
它将annoallvisible设置为0,将当前比例设置为“HB 1:200”,因此仅显示注释性对象。
然后在坐标1000000到1000000处生成一个大矩形。(我使用荷兰协调系统RD。)
将比例“NLCS\u M\u 1:200”添加到所有对象,并删除旧比例。
 
工作起来很有魅力。:-)
 
 
  1. (defun SCHALEN200NEW ( )
  2.        (setvar 'annoallvisible 0)
  3.           (command "CANNOSCALE" "HB 1:200")
  4. (setq sel200a (ssget "_CP" '((-1000000 -1000000) (-1000000 1000000) (1000000 1000000) (1000000 -1000000))))
  5. (command "_.-objectscale" sel200a "" "a" "NLCS_M_1:200" "")
  6. (setq sel200d (ssget "_CP" '((-1000000 -1000000) (-1000000 1000000) (1000000 1000000) (1000000 -1000000))))
  7. (command "_.-objectscale" sel200d "" "d" "HB 1:200" "")
  8. (command "CANNOSCALE" "NLCS_M_1:200")
  9. (princ)
  10. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 09:10 , Processed in 1.567653 second(s), 60 queries .

© 2020-2025 乐筑天下

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