(defun C:OPB (/ *good-files* acapp adoc file_obj full-names-list osd)
(alert
"\nPlease wait a minute
\nto ending of batch file operation"
)
(vl-load-com)
(setq acapp (vlax-get-acad-object)
adoc(vla-get-activedocument acapp)
)
(vla-startundomark adoc)
(setq osd (vla-getvariable adoc "SDI"))
(vla-setvariable adoc "SDI" 0)
(setq olsp (vla-getvariable adoc "LISPINIT"))
(vla-setvariable adoc "LISPINIT" 0)
(if (setq full-names-list
(list-dwg (browse-folder "SELECT FOLDER" "C:\\"))
)
; change on your start path folder
(progn
(mapcar
(function
(lambda (i)
(progn
(setq file_obj (vla-open (vla-get-documents acapp) i))
(setq *good-files* (cons file_obj *good-files*))
;;here will your batch function:
(REPSTRING "TEXT1" "TEXT2")
(vla-setvariable file_obj "mirrtext" 0)
; (vla-setvariable file_obj "insunits" 0)
; (vla-setvariable file_obj "annotativedwg" 0)
(vla-close file_obj :vlax-true)
(vlax-release-object file_obj)
(setq file_obj nil)
)
)
)
full-names-list
)
(cond ((zerop (length *good-files*))
(princ "\nThere isn't opened files\n")
)
((not (eq (length full-names-list) (length *good-files*)))
(princ "\nSome files is not opened\n")
)
(T nil)
)
)
(princ "\nThere isn't .DWG files in selected directory\n")
)
(vla-setvariable adoc "SDI" osd)
(vla-setvariable adoc "LISPINIT" olsp)
(vla-endundomark adoc)
(princ)
)
我以这种形式运行了这个程序,但它不会替换文本,但不会出现任何错误。 看起来字符串替换函数是区分大小写的-请记住这一点。 这可能对您更有效:
8
旧代码仅替换字符串的第一个匹配项,这将替换所有匹配项。
此外,这包括多重引线。
李 这是我设置的:
9我只是一直得到**没有找到文本或属性块**
没有更改任何文本 啊,当然!
您正在activedoc之外操作。。。这不允许所有命令调用/ent*方法和SELSET。。
好的,请容忍我一点。 试试这个:
10{Untested} 它没有EROR,也没有那个消息,但是文本没有任何变化。 很抱歉,代码已更新,在使用文档集合打开图形时,可能需要额外一行进行保存。
完美的谢谢李。
页:
1
[2]