Đến nội dung


Hình ảnh
5 stars - based on 24598 reviews
* * * * * 1 Bình chọn

Lisp Chuyển Đổi Mã Font Chữ Trong Autocad


  • Please log in to reply
62 replies to this topic

#61 conghoa

conghoa

    biết lệnh divide

  • Members
  • PipPipPipPipPipPip
  • 441 Bài viết
Điểm đánh giá: 92 (tàm tạm)

Đã gửi 21 October 2016 - 02:59 PM

Nhờ mọi người giúp đỡ mình cái file này lỗi font gì? mình xin cảm ơn!

mình up file nó chạy lâu quá nên mình up lên media http://www.mediafire...5/lỗi_font.rar 

File của bạn có bị lỗi gì đâu, bạn chuyển toàn bộ file đó về style text nào có mã font tcvn3(ABC) là được


  • 1

#62 quangphuong1112

quangphuong1112

    biết pan

  • Members
  • Pip
  • 6 Bài viết
Điểm đánh giá: -1 (bình thường)

Đã gửi 25 October 2016 - 05:27 PM

Cảm ơn bạn vì lisp convertfont.vlx  của bạn, nó quá hữu ích.

mình loay hoay sửa font mãi mà k biết font nào đúng, có khi còn không có, dùng cái này là giải quết hết vấn đề font.!

Thanks you very much!!!!!!!!!!!!!!!!


  • 0

#63 snowman.hms

snowman.hms

    biết vẽ pline

  • Members
  • PipPip
  • 64 Bài viết
Điểm đánh giá: 30 (tàm tạm)

Đã gửi 12 December 2016 - 11:28 AM

(defun c:convertfont nil
  (setq
    UNI '((225) (224) (92 85 43 49 69 65 51) (92 85 43 48 48 69 51) (92 85 43 49 69 65 49)
	 (227) (92 85 43 49 69 65 70) (92 85 43 49 69 66 49) (92 85 43 49 69 66 51)
	 (92 85 43 49 69 66 53) (92 85 43 49 69 66 55) (226) (92 85 43 49 69 65 53)
	 (92 85 43 49 69 65 55) (92 85 43 49 69 65 57) (92 85 43 49 69 65 66)
	 (92 85 43 49 69 65 68) (233) (232) (92 85 43 49 69 66 66) (92 85 43 49 69 66 68)
	 (92 85 43 49 69 66 57) (234) (92 85 43 49 69 66 70) (92 85 43 49 69 67 49)
	 (92 85 43 49 69 67 51) (92 85 43 49 69 67 53) (92 85 43 49 69 67 55) (237)
	 (92 85 43 48 48 69 67) (92 85 43 49 69 67 57) (92 85 43 48 49 50 57)
	 (92 85 43 49 69 67 66) (243) (92 85 43 48 48 70 50) (92 85 43 49 69 67 70)
	 (92 85 43 48 48 70 53) (92 85 43 49 69 67 68) (244) (92 85 43 49 69 68 49)
	 (92 85 43 49 69 68 51) (92 85 43 49 69 68 53) (92 85 43 49 69 68 55)
	 (92 85 43 49 69 68 57) (245) (92 85 43 49 69 68 66) (92 85 43 49 69 68 68)
	 (92 85 43 49 69 68 70) (92 85 43 49 69 69 49) (92 85 43 49 69 69 51) (250)
	 (249) (92 85 43 49 69 69 55) (92 85 43 48 49 54 57) (92 85 43 49 69 69 53)
	 (253) (92 85 43 49 69 69 57) (92 85 43 49 69 69 66) (92 85 43 49 69 69 68)
	 (92 85 43 49 69 69 70) (92 85 43 49 69 70 49) (92 85 43 48 48 70 68)
	 (92 85 43 49 69 70 51) (92 85 43 49 69 70 55) (92 85 43 49 69 70 57)
	 (92 85 43 49 69 70 53) (240);
	 (193) (192) (92 85 43 49 69 65 50) (92 85 43 48 48 67 51) (92 85 43 49 69 65 48)
         (195) (92 85 43 49 69 65 69) (92 85 43 49 69 66 48) (92 85 43 49 69 66 50)
         (92 85 43 49 69 66 52) (92 85 43 49 69 66 54) (194) (92 85 43 49 69 65 52)
         (92 85 43 49 69 65 54) (92 85 43 49 69 65 56) (92 85 43 49 69 65 65)
         (92 85 43 49 69 65 67) (201) (200) (92 85 43 49 69 66 65) (92 85 43 49 69 66 67)
         (92 85 43 49 69 66 56) (202) (92 85 43 49 69 66 69) (92 85 43 49 69 67 48)
         (92 85 43 49 69 67 50) (92 85 43 49 69 67 52) (92 85 43 49 69 67 54) (205)
         (92 85 43 48 48 67 67) (92 85 43 49 69 67 56) (92 85 43 48 49 50 56)
         (92 85 43 49 69 67 65) (211) (92 85 43 48 48 68 50) (92 85 43 49 69 67 69)
         (92 85 43 48 48 68 53) (92 85 43 49 69 67 67) (212) (92 85 43 49 69 68 48)
         (92 85 43 49 69 68 50) (92 85 43 49 69 68 52) (92 85 43 49 69 68 54)
         (92 85 43 49 69 68 56) (213) (92 85 43 49 69 68 65) (92 85 43 49 69 68 67)
         (92 85 43 49 69 68 69) (92 85 43 49 69 69 48) (92 85 43 49 69 69 50) (218)
         (217) (92 85 43 49 69 69 54) (92 85 43 48 49 54 56) (92 85 43 49 69 69 52)
         (221) (92 85 43 49 69 69 56) (92 85 43 49 69 69 65) (92 85 43 49 69 69 67)
         (92 85 43 49 69 69 69) (92 85 43 49 69 70 48) (92 85 43 48 48 68 68)
         (92 85 43 49 69 70 50) (92 85 43 49 69 70 54) (92 85 43 49 69 70 56)
         (92 85 43 49 69 70 52) (208))
    TCVN '((184) (181) (182) (183) (185) (168) (190) (187) (188) (189) (198) (169) (202)
	 (199) (200) (201) (203) (92 85 43 48 48 68 48) (92 85 43 48 48 67 67) (206)
	 (207) (209) (170) (92 85 43 48 48 68 53) (92 85 43 48 48 68 50) (211) (212)
	 (214) (92 85 43 48 48 68 68) (215) (216) (220) (92 85 43 48 48 68 69)
	 (92 85 43 48 48 69 51) (223) (225) (226) (228) (171) (232) (229) (230) (231)
	 (233) (172) (237) (234) (235) (92 85 43 48 48 69 67) (238) (243) (239) (241)
	 (92 85 43 48 48 70 50) (244) (173) (248) (92 85 43 48 48 70 53) (246) (247)
	 (249) (92 85 43 48 48 70 68) (250) (251) (252) (92 85 43 48 48 70 69) (174);
	 (184) (181) (182) (183) (185) (161) (190) (187) (188) (189) (198) (162) (202)
         (199) (200) (201) (203) (92 85 43 48 48 68 48) (92 85 43 48 48 67 67) (206)
         (207) (209) (163) (92 85 43 48 48 68 53) (92 85 43 48 48 68 50) (211) (212)
         (214) (92 85 43 48 48 68 68) (215) (216) (220) (92 85 43 48 48 68 69)
         (92 85 43 48 48 69 51) (223) (225) (226) (228) (164) (232) (229) (230) (231)
         (233) (165) (237) (234) (235) (92 85 43 48 48 69 67) (238) (243) (239) (241)
         (92 85 43 48 48 70 50) (244) (166) (248) (92 85 43 48 48 70 53) (246) (247)
         (249) (92 85 43 48 48 70 68) (250) (251) (252) (92 85 43 48 48 70 69) (167))
    VNI '((97 249) (97 248) (97 251) (97 92 85 43 48 48 70 53) (97 239) (97 234)
         (97 233) (97 232) (97 250) (97 252) (97 235) (97 226) (97 225) (97 224)
         (97 229) (97 92 85 43 48 48 69 51) (97 228) (101 249) (101 248) (101 251)
         (101 92 85 43 48 48 70 53) (101 239) (101 226) (101 225) (101 224) (101 229)
         (101 92 85 43 48 48 69 51) (101 228) (237) (92 85 43 48 48 69 67) (230) (243)
         (92 85 43 48 48 70 50) (111 249) (111 248) (111 251) (111 92 85 43 48 48 70 53)
         (111 239) (111 226) (111 225) (111 224) (111 229) (111 92 85 43 48 48 69 51)
         (111 228) (244) (244 249) (244 248) (244 251) (244 92 85 43 48 48 70 53) (244 239)
         (117 249) (117 248) (117 251) (117 92 85 43 48 48 70 53) (117 239) (246) (246 249)
         (246 248) (246 251) (246 92 85 43 48 48 70 53) (246 239) (121 249) (121 248)
         (121 251) (121 92 85 43 48 48 70 53) (238) (241);
	 (65 217) (65 216) (65 219) (65 92 85 43 48 48 68 53)
         (65 207) (65 202) (65 201) (65 200) (65 218) (65 220)
         (65 203) (65 194) (65 193) (65 192) (65 197) (65 92 85 43 48 48 67 51)
         (65 196) (69 217) (69 216) (69 219) (69 92 85 43 48 48 68 53) (69 207)
         (69 194) (69 193) (69 192) (69 197) (69 92 85 43 48 48 67 51) (69 196)
         (205) (92 85 43 48 48 67 67) (198) (211) (92 85 43 48 48 68 50) (79 217)
         (79 216) (79 219) (79 92 85 43 48 48 68 53) (79 207) (79 194) (79 193)
         (79 192) (79 197) (79 92 85 43 48 48 67 51) (79 196) (212) (212 217) (212 216)
         (212 219) (212 92 85 43 48 48 68 53) (212 207) (85 217) (85 216) (85 219)
         (85 92 85 43 48 48 68 53) (85 207) (214) (214 217) (214 216) (214 219)
         (214 92 85 43 48 48 68 53) (214 207) (89 217) (89 216) (89 219)
         (89 92 85 43 48 48 68 53) (206) (209))
  )
  (mapcar '(lambda (a b c)
	     (eval (vl-list* 'defun (read (strcat "c:" a)) 'nil (list 'cf::convertfont b c) '((princ))))
	   )
	  '("t2u" "t2v" "u2t" "u2v" "v2t" "v2u")
	  '(tcvn tcvn uni uni vni vni)
	  '(uni vni tcvn vni tcvn uni)
  )
  (princ)
)
(defun cf::convertfont (c1 c2 / s i e el h l ol sl c n str mtx t0 t1 doc
			*error* _StartUndo _EndUndo)
  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )  
  (defun _StartUndo ( doc ) (_EndUndo doc)
    (vla-StartUndoMark doc)
  )
  (defun _EndUndo ( doc )
    (if (= 8 (logand 8 (getvar 'UNDOCTL)))
      (vla-EndUndoMark doc)
    )
  )  
  (initget "Lower Upper Normal")
  (setq	#case (cond ((getkword (strcat "\nSpecify Case-Sensitiy option: [Lower/Upper/Normal] <"
				       (setq #case (cond (#case) ("Normal"))) ">: ")))
		    (#case)
	      )
        doc (vla-get-ActiveDocument (vlax-get-acad-object))
	sl 0
	ol 0
  )
  (cond	((= #case "Lower") (setq c2 (cf::sublist (/ (length c2) 2) c2) c 1))
	((= #case "Upper") (setq c2 (reverse (cf::sublist (/ (length c2) 2) (reverse c2))) c 2))
	((setq c 0))
  )
  (if (and (princ "\nSelect a [M]TEXT: ") (setq s (ssget '((0 . "*TEXT")))))
    (progn
      (_StartUndo doc)
      (setq t0 (getvar "MilliSecs"))
      (repeat (setq i (sslength s))
	(setq e   (ssname s (setq i (1- i)))
	      el  (entget e)
	      h   (reverse (cdr (member (cond ((assoc 3 el)) ((assoc 1 el))) (reverse el))))
	      str (LM:UnFormat (cf::GetTextString el) (setq mtx (equal (cdr (assoc 0 el)) "MTEXT")))
	      sl  (+ (strlen str) sl)
	      ol  (1+ ol)
	      el  (cdr (member (assoc 1 el) el))
	)
	(setq str (apply (function append) (cf::ff0 str c1 c2 (length c2) c)))
	(if mtx
	  (progn
	    (setq str  (gbn str 250))
	    (repeat (1- (length str))
	      (setq l (cons (cons 3 (vl-list->string (car str))) l)
		    str (cdr str)))
	    (setq l (cons (cons 1 (vl-list->string (vl-remove nil (car str)))) l)
		  l (reverse l))
	  )
	  (setq l (cons (cons 1 (vl-list->string str)) l)) 
	)	
	(entmod (append h l el))
      )
      (setq t1 (getvar "MilliSecs"))
      (princ (strcat "\nTotal time to conver ["(rtoc ol 0)" - Objects] with [String length: " (rtoc sl 0) "] is : "
		     (rtoc (- t1 t0) 0) " (ms)"))
      (_EndUndo doc)
    )
    (princ "\nNo Valid object selected!!!")
  )
  (princ)
)
(defun cf::ff0 (s c1 c2 n c / a p r)
  ; c = 1: lower
  ; c = 2: upper
  ; c = 0: normal
  (if (= (type s) 'str) (setq s (vl-string->list s)))
  (cond ((= 8 (apply (function max) (mapcar (function length) c1)))
	 (if (and (= (car s) 92) (setq p (vl-position (cf::f7 s) c1)))
	   (setq r (cons (nth (rem p n) c2) r)
		 s (cdddr (cddddr s))
	   )
	 )
	 (while s
	   (cond 
		 ((= (cadr s) 92)
		  (cond ((setq p (vl-position (cf::f8 s) c1))
			 (setq r (cons (nth (rem p n) c2) r) s (cddddr (cddddr s))))
			(t
			 (if (setq p (vl-position (list (car s)) c1))
			   (setq r (cons (nth (rem p n) c2) r) s (cdr s))
			   (cond ((= c 1)
				  (if (< 64 (car s) 91)
				    (setq r (cons (list (+ (car s) 32)) r) s (cdr s))
				    (setq r (cons (list (car s)) r) s (cdr s))))
				 ((= c 2)
				  (if (< 96 (car s) 123)
				    (setq r (cons (list (- (car s) 32)) r) s (cdr s))
				    (setq r (cons (list (car s)) r) s (cdr s))))
				 (t (setq r (cons (list (car s)) r) s (cdr s)))
			   )
			 )
			 (if (setq p (vl-position (cf::f7 s) c1))
			   (setq r (cons (nth (rem p n) c2) r) s (cdddr (cddddr s)))
			   (setq r (cons (list (car s)) r) s (cdr s))
			 )
			)
		  )
		 )
		 ((setq p (vl-position (cf::f2 s) c1))
		  (setq r (cons (nth (rem p n) c2) r) s (cddr s)))
		 ((setq p (vl-position (list (car s)) c1))
		  (setq r (cons (nth (rem p n) c2) r) s (cdr s)))
		 ((vl-position c '(0 1 2))
		  (cond ((= c 1)
			 (if (< 64 (car s) 91)
			   (setq r (cons (list (+ (car s) 32)) r) s (cdr s))
			   (setq r (cons (list (car s)) r) s (cdr s))))
			((= c 2)
			 (if (< 96 (car s) 123)
			   (setq r (cons (list (- (car s) 32)) r) s (cdr s))
			   (setq r (cons (list (car s)) r) s (cdr s))))
			(t (setq r (cons (list (car s)) r) s (cdr s)))
		  )
		 )
	   )
	 )
        )
	(t (while s
	     (cond ((= (car s) 92)
		    (if (setq p (vl-position (cf::f7 s) c1))
		      (setq r (cons (nth (rem p n) c2) r) s (cdddr (cddddr s)))
		      (setq r (cons (list (car s)) r) s (cdr s))
		    )
		   )		   
		   ((setq p (vl-position (setq a (list (car s))) c1))
		    (setq r (cons (nth (rem p n) c2) r) s (cdr s)))
		   ((vl-position c '(0 1 2))
		    (cond ((= c 1)
			   (if (< 64 (car s) 91)
			     (setq r (cons (list (+ (car s) 32)) r) s (cdr s))
			     (setq r (cons (list (car s)) r) s (cdr s))))
			  ((= c 2)
			   (if (< 96 (car s) 123)
			     (setq r (cons (list (- (car s) 32)) r) s (cdr s))
			     (setq r (cons (list (car s)) r) s (cdr s))))
			  (t (setq r (cons (list (car s)) r) s (cdr s)))
		    )
		   )
	     )
	   )
       )
  )
  (reverse r)
)
(defun cf::sublist ( n l ) (reverse (member (nth (1- n) l) (reverse l))))
(defun cf::f8 (l) (list (car l) (cadr l) (caddr l) (cadddr l) (car (setq l (cddddr l))) (cadr l) (caddr l) (cadddr l)))
(defun cf::f7 (l) (list (car l) (cadr l) (caddr l) (cadddr l) (car (setq l (cddddr l))) (cadr l) (caddr l)))
(defun cf::f2 (l) (list (car l) (cadr l)))
(defun cf::GetTextString (el / typ)
  (cond	((wcmatch (setq typ (cdr (assoc 0 el))) "TEXT,*DIMENSION") (cdr (assoc 1 (reverse el))))
	((wcmatch typ "ATTRIB,MTEXT")
	 (apply	(function strcat)
		(mapcar	(function cdr) (vl-remove-if-not (function (lambda (x) (vl-position (car x) '(1 3)))) el))
	 )
	)
  )
)
;;-------------------=={ UnFormat String }==------------------;;
;;                                                            ;;
;;  Returns a string with all MText formatting codes removed. ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  str - String to Process                                   ;;
;;  mtx - MText mtxag (T if string is for use in MText)        ;;
;;------------------------------------------------------------;;
;;  Returns:  String with formatting codes removed            ;;
;;------------------------------------------------------------;;

(defun LM:UnFormat ( str mtx / _replace rx )
    (defun _replace ( new old str )
        (vlax-put-property rx 'pattern old)
        (vlax-invoke rx 'replace str new)
    )
    (if (setq rx (vlax-get-or-create-object "VBScript.RegExp"))
        (progn
            (setq str
                (vl-catch-all-apply
                    (function
                        (lambda ( )
                            (vlax-put-property rx 'global     actrue)
                            (vlax-put-property rx 'multiline  actrue)
                            (vlax-put-property rx 'ignorecase acfalse) 
                            (foreach pair
                               '(
                                    ("\032"    . "\\\\\\\\")
                                    (" "       . "\\\\P|\\n|\\t")
                                    ("$1"      . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\
\[ACcFfHLlOopQTW]")
                                    ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);")
                                    ("$1$2"    . "\\\\(\\\\S)|[\\\\](})|}")
                                    ("$1"      . "[\\\\]({)|{")
                                )
                                (setq str (_replace (car pair) (cdr pair) str))
                            )
                            (if mtx
                                (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str))
                                (_replace "\\"   "\032" str)
                            )
                        )
                    )
                )
            )
            (vlax-release-object rx)
            (if (null (vl-catch-all-error-p str))
                str
            )
        )
    )
)
(defun GBN (l n / b lst)
  ;; http://www.theswamp.org/index.php?topic=32428.msg380205#msg380205
  ;; by Elpanov Evgeniy
 (setq b (list '(reverse a)))
 (repeat (/ n 4)
  (setq b (cons '(setq
                  a
                  (cons (cadddr l) (cons (caddr l) (cons (cadr l) (cons (car l) a))))
                  l
                  (cddddr l)
                 ) ;_  setq
                b
          ) ;_  cons
  ) ;_  setq
 ) ;_  repeat
 (setq n (rem n 4))
 (repeat (/ n 3)
  (setq b (cons '(setq
                  a
                  (cons (caddr l) (cons (cadr l) (cons (car l) a)))
                  l
                  (cdddr l)
                 ) ;_  setq
                b
          ) ;_  cons
  ) ;_  setq
 ) ;_  repeat
 (setq n (rem n 3))
 (repeat (/ n 2)
  (setq b (cons '(setq
                  a
                  (cons (cadr l) (cons (car l) a))
                  l
                  (cddr l)
                 ) ;_  setq
                b
          ) ;_  cons
  ) ;_  setq
 ) ;_  repeat
 (setq n (rem n 2))
 (repeat (/ n 1)
  (setq b (cons '(setq
                  a
                  (cons (car l) a)
                  l
                  (cdr l)
                 ) ;_  setq
                b
          ) ;_  cons
  ) ;_  setq
 ) ;_  repeat
 (eval (cons 'defun (cons 'f1 (cons '(a) b))))
 (while l (setq lst (cons (f1 nil) lst)))
 (reverse lst)
)
(defun rtoc ( n p / foo d l )
    (defun foo ( l n )
        (if (or (not (cadr l)) (= 44 (cadr l)))
            l
            (if (zerop (rem n 3))
                (vl-list* (car l) 46 (foo (cdr l) (1+ n)))
                (cons (car l) (foo (cdr l) (1+ n)))
            )
        )
    )
    (setq d (getvar 'dimzin))
    (setvar 'dimzin 0)
    (setq l (subst 44 46 (vl-string->list (rtos (abs n) 2 p))))
    (setvar 'dimzin d)
    (vl-list->string
      (append (if (minusp n) '(45))
	      (foo l (- 3 (rem (fix (/ (log (abs n)) (log 10))) 3)))
      )
    )
)
(vl-load-com)
(c:convertfont)
(princ)

  • 1