cwake 发表于 2022-7-5 23:24:31

将注释比例添加到

每次我需要向LISP中的实体添加注释比例时,我都被限制在(vl cmdf“-objectscale”sset“add”scale”的功能范围内。
 
很长一段时间以来,我一直希望能够通过扩展字典添加标尺,但我从未成功过。字典记录创建正常,但实体似乎没有继承比例,它消失了。
 
这是我在玩将文字转换为多行文字的例程。我收集原始文本实体使用的比例,然后在创建多行文字实体后,我尝试通过字典将相同的比例添加到多行文字实体。
 
有人能解释为什么它失败了吗?如果需要,我可以发布整个函数。
 
(defun addannscale (ent scales / acdbdict dict elist scdict txtocd scale)
   (entmod (setq elist (append (entget ent) '((-3 ("AcadAnnotative" (1000 . "AnnotativeData") (1002 . "{") (1070 . 1) (1070 . 1) (1002 . "}")))))));annotative
   (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
         acdbdict (dictadd dict "AcDbContextDataManager"
                           (entmakex (list '(0 . "DICTIONARY")
                                           '(100 . "AcDbDictionary")
                                           '(280 . 0)
                                           '(281 . 1)
                                           )
                                     )
                           )
         scdict (dictadd acdbdict "ACDB_ANNOTATIONSCALES"
                         (entmakex
                           (list '(0 . "DICTIONARY")
                                 '(100 . "AcDbDictionary")
                                 '(280 . 0)
                                 '(281 . 1)
                                 )
                           )
                         )
         )
   (foreach x scales
   (setq txtocd (entget (cdr x))
         scale (entget (cdr (assoc 340 txtocd)))
         )
   (dictadd scdict
            (car x)
            (entmakex (list '(0 . "ACDB_MTEXTOBJECTCONTEXTDATA_CLASS")
                              '(100 . "AcDbObjectContextData")
                              (assoc 70 txtocd)
                              (assoc 290 txtocd)
                              '(100 . "AcDbAnnotScaleObjectContextData")
                              (assoc 340 txtocd) ;The scale ename in the dictionary
                              (cons 70 (cdr (assoc 71 elist)));this is the attachment point at the time the entity was created
                              (cons 10 (cdr (assoc 11 elist)));direction vector
                              (cons 11 (cdr (assoc 10 elist)));insert point
                              '(40 . 0)
                              '(41 . 0)
                              (cons 42 (/ (* (cdr (assoc 42 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
                              (cons 43 (/ (* (cdr (assoc 43 elist)) (cdr (assoc 141 scale))) (cdr (assoc 140 scale))))
                              '(71 . 0)
                              )
                        )
            )
   );foreach
   )
 
刻度以使用以下工具检索的格式传递给函数:
 
(defun entscales (en / a b)
   (if (and (setq a (cdr (assoc 360 (entget en))))
            (setq a (dictsearch a "AcDbContextDataManager"))
            (setq a (dictsearch (cdr (assoc -1 a)) "ACDB_ANNOTATIONSCALES"))
            )
   (while (assoc 3 a)
       (setq b (cons (cons (cdr (assoc 3 a)) (cdr (assoc 350 a))) b)
             a (cddr (member (assoc 3 a) a))
             )
       )
   )
   (reverse b)
   )

irneb 发表于 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提供内容的。

cwake 发表于 2022-7-6 00:40:34

谢谢Irne。非常感谢。我现在将详细阅读这些线程。
页: [1]
查看完整版本: 将注释比例添加到