alanjt 发表于 2022-7-6 10:17:42


(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)
)

jmerch 发表于 2022-7-6 10:23:06

 
我只是说我把你的C:test改成了类似C:test1的东西,它成功了。。。。所以我必须在某个地方加载一个例程,该例程使用TEST作为命令。。。除此之外,您发布的最后一个代码按原样工作。

Tharwat 发表于 2022-7-6 10:24:32

 
是 啊就这样。
 
塔瓦特

alanjt 发表于 2022-7-6 10:26:54

请注意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字符串(不可见)。
 
塔瓦特

jmerch 发表于 2022-7-6 10:30:25

看看谁在学习。

Tharwat 发表于 2022-7-6 10:33:32

 
每天我都会听到Lisp程序的怪事。
 
当做

Tharwat 发表于 2022-7-6 10:35:46

要添加:
 
[列表=1]
[*]在这些情况下,我不会使用1 dxf代码查找文本。它区分大小写,只搜索前250个字符。
[*]我会避免使用vla get textstring,因为它有一个巨大的错误,它不会正确返回符号,而是给你一个“?”。
[/列表]

alanjt 发表于 2022-7-6 10:39:17

Tharwat 发表于 2022-7-6 10:44:55

 
Everyday I am getting odd things with Lisp.
 
Regards

alanjt 发表于 2022-7-6 10:45:59

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]
查看完整版本: 通过LISP编辑多行文字