本帖最后由 cabinsummer 于 2016-12-24 15:11 编辑
编译后的文件,免费,供淘宝者使用
命令:RC
- (defun c:rc(/ oldch newch sstxt ssl ct0 edata etext txtln subln ct1 ct2 schct DCL_ID newtext)
- (setvar "cmdecho" 0)
- (command "undo" "be")
- (setq oldch "" newch "")
- (if (> (setq DCL_ID (load_dialog "replace.dcl")) 0)
- (progn
- (if (new_dialog "replace" DCL_ID)
- (progn
- (mode_tile "oldword" 2)
- (action_tile "oldword" "(setq oldch $value)")
- (action_tile "newword" "(setq newch $value)")
- (start_dialog)
- )
- (princ "\n 不能显示对话框")
- )
- (unload_dialog DCL_ID)
- )
- (princ "\n 不能打开对话框")
- )
- (if (and (/= "" oldch)(/= oldch newch)(setq sstxt (ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(-4 . "OR>")))))
- (progn
- (setq ssl (sslength sstxt)
- ct0 0
- ct1 0
- ct2 0
- subln (strlen oldch)
- )
- (while (< ct0 ssl)
- (setq edata (entget (ssname sstxt ct0))
- etext (cdr (assoc 1 edata))
- txtln (strlen etext)
- schct 1
- newtext ""
- )
- (while (<= schct txtln)
- (setq newtext
- (strcat newtext
- (if (= (setq readch (substr etext schct subln)) oldch)
- (setq ct1 (1+ ct1)
- schct (+ schct subln)
- newch newch
- )
- (progn
- (setq schct (1+ schct))
- (substr readch 1 1)
- )
- )
- )
- )
- )
- (if (/= etext newtext)
- (progn
- (entmod (subst (cons 1 newtext) (assoc 1 edata) edata))
- (setq ct2 (1+ ct2))
- )
- )
- (setq ct0 (1+ ct0))
- )
- (alert (strcat "所选文字中共有" (itoa ct2) "个文字含" (itoa ct1) "个 \"" oldch "\" 被替换为 \"" newch "\" ."))
- )
- )
- (command "undo" "e")
- (princ)
- )
- replace:dialog
- {
- label="替换文字串中指定子串";
- :edit_box
- {
- label="目标子串";
- key="oldword";
- allow_accept=true;
- }
- :edit_box
- {
- label="替换子串";
- key="newword";
- allow_accept=true;
- }
- ok_only;
- }
|