Watson 发表于 2022-7-6 14:42:20

查找和替换脚本

你好
 
我公司的项目经理正在运行AutoCAD LT 2009。
 
我们公司使用具有以下字段的通用项目模板:
 
01区域1
01代表1
01经销商1
01乘以1
01日期1
下午1点01分
01DWG 1
 
我们使用“FIND”命令将通用信息替换为项目细节,例如,我们将找到“01DATE 1”,并将其替换为“4/20/09”。这可能有点乏味,所以我想要一个脚本来减少一些点击。理想情况下,它会运行,这样第一个字段就会弹出,我会在命令行中填写适当的信息,然后点击空格键,下一个字段就会弹出,等等…
 
自从我们进入2009年以来,我一直在研究这个问题,但一直无法解决一些问题。请记住,我正在运行LT。
 
如果有人有办法做到这一点,请让我知道。
 
谢谢

Hardeight 发表于 2022-7-6 14:47:39

我认为不可能只在命令行中运行“find”命令。如果你在脚本中使用它,这将是你真正需要的。另外,我不是脚本专家,但我不相信你会有办法在它运行时输入信息。这可以很容易地用Lisp编写,但我知道你在运行LT时所经历的痛苦。通过寻找某种LT扩展器,你会节省很多头痛和时间。

Watson 发表于 2022-7-6 14:50:55

 
这就是我害怕的。。。我们一直在挠头找工作。
 
六羟甲基三聚氰胺六甲醚。。。。“LT扩展器”,嗯?
 
谢谢

Lee Mac 发表于 2022-7-6 14:53:59

快速查找和替换LISP-仅即时编写(区分大小写):
 

(defun c:fnr(/ tStr ss)

(while (or (eq "" (setq tStr (getstring t "\nSpecify Text to Search For: ")))
            (not (setq ss (ssget "X" (list (cons 0 "*TEXT") (cons 1 tStr)))))
            (eq "" (setq rStr (getstring t "\nSpecify Replacement Text: "))))
   (princ "\n<!> No Text Specified or Nothing Found <!>"))

(foreach eLst(mapcar 'entget (mapcar 'cadr (ssnamex ss)))
   (entmod (subst (cons 1 rStr) (assoc 1 eLst) eLst)))
(princ))

Watson 发表于 2022-7-6 14:57:25

 
啊。。。要是我能用LISP就好了

Lee Mac 发表于 2022-7-6 15:00:31

 
真烦人,我同意。。

Watson 发表于 2022-7-6 15:03:21

http://img111.imageshack.us/img111/4343/help.png

BIGAL 发表于 2022-7-6 15:06:29

不久前,我试图通过这里的论坛使用Autocads查找并替换传递给它的变量,但没有用。原因是Autocad查找和替换搜索到处都会阻止文本多行文字等
 
关于Lt扩展器,它们工作得很好,我会质疑价格,比如说Intellicad,它已经准备好了lisp和VBA。我认为它应该有lisp在它的开箱即用。

Watson 发表于 2022-7-6 15:08:56

好吧,我放弃。所以“查找并替换”脚本不起作用。。。用ATTEDIT做点什么怎么样?
 
我该如何编写脚本,使OP中的字段在命令行上显示为可定义的?

Watson 发表于 2022-7-6 15:10:55

我做错了什么?
Command: -ATTEDIT
Edit attributes one at a time? <Y>: N
Performing global editing of attribute values.
Edit only attributes visible on screen? <Y>: N
Drawing must be regenerated afterwards.
Enter block name specification <*>: A$C49561ED3
Enter attribute tag specification <*>: AAAA
Enter attribute value specification <*>: 01AREA 1
1 attributes selected.
Enter string to change: 01AREA 1
Enter new string: \
Command: -ATTEDIT
Edit attributes one at a time? <Y>: N
Performing global editing of attribute values.
Edit only attributes visible on screen? <Y>: N
Drawing must be regenerated afterwards.
Enter block name specification <*>: A$C49561ED3
Enter attribute tag specification <*>: AAAA
Enter attribute value specification <*>: 01REP 1
1 attributes selected.
Enter string to change: 01REP 1
Enter new string: \
 
它不是在有“\”的地方暂停,而是将我的字符串命名为“\”。我希望该字段可以由用户定义。
页: [1] 2
查看完整版本: 查找和替换脚本