Corro 发表于 2022-7-5 17:45:00

使用formatti将多行文字添加到dim

早上好
我正在尝试向维度添加附加文本,如多行文字。
要求是新的多行文字位于尺寸线下方,高度为1.3mm,颜色为红色。原文高度为1.8,颜色为白色。
我附上了一个样本的要求,作为屏幕抓取。
提前谢谢。

BIGAL 发表于 2022-7-5 17:52:20

这里有一些编辑多行文字、设置颜色和高度等的例子。方法是执行3行dim,然后通过lisp单击dim,它将更改为所需的设置。我正在努力记住我将努力找到的主题,我知道李·麦克也提供了帖子。

nod684 发表于 2022-7-5 17:54:49

我不记得从哪里得到这个代码,但我一直在使用它:


(defun c:txt2dim (/ edim text etxt vla_dim cmd1)
(prompt "\nText to Dimension")
(setq cmd1 (getvar 'cmdecho))
(setvar 'cmdecho 0)
(vl-load-com)
(while
(or (initget 1)
(not (setq edim (entsel "\nSelect dimension: ")))
(/= (cdr (assoc 0 (entget (car edim)))) "DIMENSION")
)
(prompt "\n*** You must select a dimension. ***")
)
(while
(and
(not
(and (setq etxt (entsel "\nSelect text to add to override or enter to type: "))
   (= (cdr (assoc 0 (entget (car etxt)))) "TEXT")
)
)
(or (initget 1)
(not
   (setq text (getstring t "\nType the text or ENTER to clear override: "))
)
)
)
)
(if etxt
(setq text (vla-get-textstring (vlax-ename->vla-object (car etxt))))
)
(setq vla_dim (vlax-ename->vla-object (car edim)))
(cond
((and text (/= text ""))
(vla-put-textoverride vla_dim (strcat (chr 60)(chr 62) "\\X" text))
)
((and text (= text "")) ; clear the override
(vla-put-textoverride vla_dim text)
)
)
(setvar 'cmdecho cmd1)
(princ)
)

BIGAL 发表于 2022-7-5 17:59:06

也看看这个http://www.cadtutor.net/forum/showthread.php?92585-帮助仅更改多行文字中数字的颜色&高亮显示=多行文字

guran 发表于 2022-7-5 18:02:30

为什么不将文字添加到标注文字中,按ENTER键创建新行,并将文字格式设置为任意多行文字对象。您可以在AutoCad 2016中执行此操作。

Lee Mac 发表于 2022-7-5 18:06:34

下面是一个非常简单的示例:
(defun c:dimtest ( / e i s )
   (if (setq s (ssget "_:L" '((0 . "*DIMENSION") (1 . "~*?*"))))
       (repeat (setq i (sslength s))
         (setq e (entget (ssname s (setq i (1- i)))))
         (entmod (subst '(1 . "<>\\X{\\C1;This is a\\Ptest of text}") (assoc 1 e) e))
       )
   )
   (princ)
)

iconeo 发表于 2022-7-5 18:11:53

 
这将使所有文本都位于行上方。我相信他想要的功能更像李所做的,通过编程在后面添加X来进入下一行。

iconeo 发表于 2022-7-5 18:16:19

 
既然我们搞砸了。。。dimtext是否可以左对齐或右对齐?不仅要对齐文本框,还要对齐框内的文本。

Lee Mac 发表于 2022-7-5 18:20:25

 
据我所知不是这样。

Corro 发表于 2022-7-5 18:21:03

谢谢大家
 
 
像往常一样,你们统治。
 
 
一个问题是,添加的文本是否可以是多行文字,因为每次插入时添加的文本都会发生变化。
 
 
再次感谢
页: [1] 2
查看完整版本: 使用formatti将多行文字添加到dim