每次我需要向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) )