本帖最后由 jia_jg 于 2023-8-17 10:26 编辑
画图过程中发现某些字体乱码,这些问题编辑一下或换个样式再换回来均能显示正常,基于此写下以下代码解决此问题:
- (defun C:RGT ( )
- (setvar "cmdecho" 0)
- (vl-load-com)
- (setq ss (ssget "X" '((0 . "DIMENSION,TEXT,MTEXT"))))
- (if ss
- (progn
- (setq len (sslength ss))
- (setq n 0)
- (repeat len
- (setq ent (ssname ss n))
- (setq entdata (entget ent))
- (if (assoc 1 entdata)
- (progn
- (setq txt (cdr (assoc 1 entdata)))
- (setq entdata (subst '(1 . "") (assoc 1 entdata) entdata))
- (entmod entdata)
- (setq entdata (subst (cons 1 txt) (assoc 1 entdata) entdata))
- (entmod entdata)
- )
- )
- (setq n (+ 1 n))
- )
- )
- )
- (setq acadObj (vlax-get-acad-object))
- (setq doc (vla-get-activedocument acadObj))
- ; (setq mspace (vla-get-mspace doc))
- (setq n 0)
- (setq Blocks (vla-get-blocks doc))
- (vlax-for temptBlock Blocks ;vla-item Blocks 2
- (if (> n 1)
- (progn
- (setq blk_name (vla-get-Name temptBlock))
- (setq blkr (tblsearch "block" blk_name)) ;获取 存储块的链表
- (setq blkent (cdr (assoc -2 blkr))) ;获取块的第一个组成实体
- (setq blkentdata (entget blkent))
- (setq datatype (cdr (assoc 0 blkentdata)))
- (if (or (= datatype "MTEXT") (= datatype "TEXT") (= datatype "DIMENSION"))
- (progn
- (setq txt (cdr (assoc 1 blkentdata)))
- (setq blkentdata (subst '(1 . "") (assoc 1 blkentdata) blkentdata))
- (entmod blkentdata)
- (setq blkentdata (subst (cons 1 txt) (assoc 1 blkentdata) blkentdata))
- (entmod blkentdata)
- (print txt)
- )
- )
- (setq blkent (entnext blkent)) ;获取块的第二个组成实体
- (while blkent
- (setq blkentdata (entget blkent))
- (setq datatype (cdr (assoc 0 blkentdata)))
- (if (or (= datatype "MTEXT") (= datatype "TEXT") (= datatype "DIMENSION"))
- (progn
- (setq txt (cdr (assoc 1 blkentdata)))
- (setq blkentdata (subst '(1 . "") (assoc 1 blkentdata) blkentdata))
- (entmod blkentdata)
- (setq blkentdata (subst (cons 1 txt) (assoc 1 blkentdata) blkentdata))
- (entmod blkentdata)
- (print txt)
- )
- )
- (setq blkent (entnext blkent))
- )
- )
- )
- (setq n (+ 1 n))
- )
- (command "REGEN")
- (prin1)
- )
请各位老师指点: |