乐筑天下

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

[编程交流] 将注释比例添加到

[复制链接]

1

主题

116

帖子

115

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 23:24:31 | 显示全部楼层 |阅读模式
每次我需要向LISP中的实体添加注释比例时,我都被限制在(vl cmdf“-objectscale”sset“add”scale”的功能范围内。
 
很长一段时间以来,我一直希望能够通过扩展字典添加标尺,但我从未成功过。字典记录创建正常,但实体似乎没有继承比例,它消失了。
 
这是我在玩将文字转换为多行文字的例程。我收集原始文本实体使用的比例,然后在创建多行文字实体后,我尝试通过字典将相同的比例添加到多行文字实体。
 
有人能解释为什么它失败了吗?如果需要,我可以发布整个函数。
 
  1. (defun addannscale (ent scales / acdbdict dict elist scdict txtocd scale)
  2.    (entmod (setq elist (append (entget ent) '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}")))))));annotative
  3.    (setq dict (vlax-vla-object->ename (vla-getextensiondictionary (vlax-ename->vla-object ent)));this will get or if not present create the entity extension dictionary
  4.          acdbdict (dictadd dict "AcDbContextDataManager"
  5.                            (entmakex (list '(0 . "DICTIONARY")
  6.                                            '(100 . "AcDbDictionary")
  7.                                            '(280 . 0)
  8.                                            '(281 . 1)
  9.                                            )
  10.                                      )
  11.                            )
  12.          scdict (dictadd acdbdict "ACDB_ANNOTATIONSCALES"
  13.                          (entmakex
  14.                            (list '(0 . "DICTIONARY")
  15.                                  '(100 . "AcDbDictionary")
  16.                                  '(280 . 0)
  17.                                  '(281 . 1)
  18.                                  )
  19.                            )
  20.                          )
  21.          )
  22.    (foreach x scales
  23.      (setq txtocd (entget (cdr x))
  24.            scale (entget (cdr (assoc 340 txtocd)))
  25.            )
  26.      (dictadd scdict
  27.               (car x)
  28.               (entmakex (list '(0 . "ACDB_MTEXTOBJECTCONTEXTDATA_CLASS")
  29.                               '(100 . "AcDbObjectContextData")
  30.                               (assoc 70 txtocd)
  31.                               (assoc 290 txtocd)
  32.                               '(100 . "AcDbAnnotScaleObjectContextData")
  33.                               (assoc 340 txtocd) ;The scale ename in the dictionary
  34.                               (cons 70 (cdr (assoc 71 elist)));this is the attachment point at the time the entity was created
  35.                               (cons 10 (cdr (assoc 11 elist)));direction vector
  36.                               (cons 11 (cdr (assoc 10 elist)));insert point
  37.                               '(40 . 0)
  38.                               '(41 . 0)
  39.                               (cons 42 (/ (* (cdr (assoc 42 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
  40.                               (cons 43 (/ (* (cdr (assoc 43 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
  41.                               '(71 . 0)
  42.                               )
  43.                         )
  44.               )
  45.      );foreach
  46.    )

 
刻度以使用以下工具检索的格式传递给函数:
 
  1. (defun entscales (en / a b)
  2.    (if (and (setq a (cdr (assoc 360 (entget en))))
  3.             (setq a (dictsearch a "AcDbContextDataManager"))
  4.             (setq a (dictsearch (cdr (assoc -1 a)) "ACDB_ANNOTATIONSCALES"))
  5.             )
  6.      (while (assoc 3 a)
  7.        (setq b (cons (cons (cdr (assoc 3 a)) (cdr (assoc 350 a))) b)
  8.              a (cddr (member (assoc 3 a) a))
  9.              )
  10.        )
  11.      )
  12.    (reverse b)
  13.    )
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 00:07:22 | 显示全部楼层
我对这个问题已经有很长一段时间了。到了我不再尝试的地步。E、 g.我第一次接触注释和词典是在2008年:
 
[列表]
  • http://forums.augi.com/showthread.php?70935-将注释比例与视口比例匹配&p=917059&viewfull=1#post917059
  • http://forums.augi.com/showthread.php?83984-注释性对象&p=867530&viewfull=1#post867530
    [/列表]
     
    如果您无法通过命令调用使其正常工作,那么我建议您采用DotNet路线。甚至添加了一些lisp可调用函数。也许可以在这个论坛上提问:http://forums.augi.com/forumdisplay.php?1417-弥合间隙LISP NET LISP
    它是专门讨论从DotNet中向lisp提供内容的。
  • 回复

    使用道具 举报

    1

    主题

    116

    帖子

    115

    银币

    初来乍到

    Rank: 1

    铜币
    5
    发表于 2022-7-6 00:40:34 | 显示全部楼层
    谢谢Irne。非常感谢。我现在将详细阅读这些线程。
    回复

    使用道具 举报

    发表回复

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

    本版积分规则

    • 微信公众平台

    • 扫描访问手机版

    • 点击图片下载手机App

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

    GMT+8, 2025-3-11 00:31 , Processed in 0.650841 second(s), 58 queries .

    © 2020-2025 乐筑天下

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