(defun c:test (/ new ss)(vl-load-com)
; Tharwat 24.02. 2010
(if (and (setq new (getstring T "Enter New Text: "))
(setq ss (ssget "_X" '((0 . "MTEXT") (1 . "test"))))
)
((lambda (i / ss1)
(while
(setq ss1 (ssname ss (setq i (1+ i))))
(vla-put-textstring (vlax-ename->vla-object ss1) new)
)
)
-1
)
(Alert
"\n Your replaced text is not found in the drawing....."
)
)
(princ)
)
我只是说我把你的C:test改成了类似C:test1的东西,它成功了。。。。所以我必须在某个地方加载一个例程,该例程使用TEST作为命令。。。除此之外,您发布的最后一个代码按原样工作。
是 啊就这样。
塔瓦特 请注意jmerch,如果您打算使用我已经为您发布的任何例程,您应该修改
常规。。。。。。这就是。
(defun c:Test (/ ss str)
(if (and (setq ss (ssget "_X" '((0 . "MTEXT") (1 . "TEST")))) ; select mtext
(/= "" (setq str (getstring T "\nSpecify string: "))) ; specify string & /= ""
)
(progn
;; below steps through active selectionset
(vlax-for obj (setq ss (vla-get-activeselectionset ; active selectionset
(vla-get-activedocument (vlax-get-acad-object))
)
)
(vla-put-textstring obj str)
)
(vla-delete ss) ; delete selection set (not acutal objects, just the selection set)
)
)
(princ)
)
因为如果用户使用例程并按enter键而不是支持字符串,则例程会将找到的mtext替换为nil字符串(不可见)。
塔瓦特 看看谁在学习。
每天我都会听到Lisp程序的怪事。
当做 要添加:
[列表=1]
[*]在这些情况下,我不会使用1 dxf代码查找文本。它区分大小写,只搜索前250个字符。
[*]我会避免使用vla get textstring,因为它有一个巨大的错误,它不会正确返回符号,而是给你一个“?”。
[/列表]
Everyday I am getting odd things with Lisp.
Regards To add:
[*] In these situations, I would stay clear of using the 1 dxf code for finding text. It's case sensitive and only searches the first 250 characters.
[*]I would avoid the use of vla-get-textstring since there is a huge bug in that it will not return a symbol properly, and instead give you a "?".
页:
1
[2]