726613 发表于 2014-9-19 12:26:49

请问如何将文字样式修改程序

把CAD文档中的文字样式"mychina"转换成"standard"的程序,请大家指教,如何编写程序?

maiko 发表于 2014-9-19 13:43:59

更新组码7.

永不言弃 发表于 2014-9-19 14:09:11

(defun c:tt()
(setq ss (ssget))
(setq        ssn (sslength ss))
(setq n 0)
(repeat ssn
    (setq en(ssname ss n))
    (setq ob (vlax-ename->vla-object en))
    (vla-put-StyleName ob "standard")
    (setq n (1+ n))
    )
(print (strcat "共更新" (rtos ssn 2 0) "个对象"))
(princ)
)

香田里浪人 发表于 2014-9-19 18:51:15

;修改文字的字体   
(defun *error*(st)
(princ (strcat "错误: " st))
(princ)
)
(defun C:xgzt(/ test ss len n en1 a oldr newr ent nn)
(setvar "CMDECHO" 0)
(setq test T nn 0)
(while test
    (setq ss (ssadd))
    (setq ss (ssget))
    (if (= nil ss)
      (setq test nil)
      (progn
        (setq len (sslength ss))
        (setq n 1 s 1)
        (while (<= n len)
          (setq en1 (ssname ss (1- n)))
          (setq a (entget en1))
          (if(= "TEXT" (cdr (assoc 0 a)))
          (progn
              (if (= s 1)
                (progn
                  (setq oldr (cdr (assoc 7 a)))
                  (setq newr (strcase (getstring (strcat "\n新字体 <" oldr ">:"))))
                  (if (= newr "") (setq newr oldr))
                  (setq s nil)
                )
              )
            (if (= (tblsearch "style" newr) nil)
                (progn
                  (cond ((= newr "XW")
                        (command "STYLE" "xw" "txt" "0" ".8" "0" "n" "n" "n"))
                        ((= newr "HZ")
                        (command "STYLE" "hz" "txt,hztxt" "0" ".8" "0" "n" "n" "n"))
                        ((= newr "CHINA")
                        (command "STYLE" "china" "txt,china" "0" ".8" "0" "n" "n" "n"))
                        ((= newr "LM")
                        (command "STYLE" "lm" "complex" "0" ".8" "0" "n" "n" "n"))
                        (T (princ (strcat "\nPlease define style " newr " use STYLE command !")))
                  )
                )
            )
            (setq ent (subst (cons 7 newr) (assoc 7 a) a))
              (entmod ent)
            (setq nn (1+ nn))
          )
页: [1]
查看完整版本: 请问如何将文字样式修改程序