明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 9779|回复: 9

[求助]打开图纸开始时能否自动替换字体

[复制链接]
发表于 2007-1-31 19:32:00 | 显示全部楼层 |阅读模式

打开图纸开始时能自动替换字体的lisp:打开CAD图纸没有勾选大字体的勾选并用gbcbig代替,找不到英文字体的自动替换为txt,并选取大字体用gbcbig代替

我下面的例图:aa8.dwg,您下载用AutoCAD R14打开时会提示:

第一次提示  specfy font for fontalt 要求我选字体
我选择Hztxt
第二次提示  select shape file  要求我选自定义的字体
我选择Ex.shp

这个问题还挺关键的,如果打开图纸,选择字体时按"取消",后面程序中凡是有用"insert"命令时,程序就会出错.

不知道字体信息存在什么地方了,(系统变量里没有)

而且我每次打开图都有这个提示。

***注意:不是打开图之后,才替换字体,是打开一张图时,能否自动cad对字体的提问。

请斑竹指点一下吧!谢谢了。我怎么才能不用每次回答提示啊?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2007-2-1 19:09:00 | 显示全部楼层
你在surport目录下找一个叫acad.fmp的文件,在那里面修改一下就行了,不过你的先知道哪个你没有的字体名字,在specfy font for fontalt 时会有提示,但是有的时候也不行,我也没搞太懂
发表于 2007-2-1 19:24:00 | 显示全部楼层
这样的程序仅见过一个高人写过,  ARX 程序用于 CAD2002,加载后只要打开图自动在后台按 INI 配置的字体自动替换,不会出现选择字体对话框
发表于 2007-2-1 20:37:00 | 显示全部楼层
以下内容出自ShlispCAD,未经测试,因为我很少打开别人的图

;将不认识的字体自动替换成,自己定义的字体。
(defun c:gps_rep ( / cn elist en enl nm gps_hzstyle)

  (if (not $gps_hztxt_e) (setq $gps_hztxt_e "hztxt_e.shx"))
  (if (not $gps_hztxt)   (setq $gps_hztxt "hztxt.shx"))
  (setq gps_hzstyle (strcat $gps_hztxt_e "," $gps_hztxt ))

    (setq elist (tblnext "STYLE" T))
    (while (/= elist nil)
      (setq nm (cdr (assoc 2 elist))
            en (cdr (assoc 3 elist))
            cn (cdr (assoc 4 elist))
           enl (strlen en)
      )
      (if (and
             (/= en nil)
             (= cn nil)
             (= (findfile en) nil)
             (= (strcase (substr en (- enl 2))) "SHX")
           )
         (command "_style" nm $gps_hztxt_e "0.0" "0.7" "" "" "" "")
      )
      (if (and
             (/= cn nil)
             (= (findfile cn) nil)
           )
         (command "_style" nm  gps_hzstyle "0.0" "0.7" "" "" "" "")
      )
     (setq elist (tblnext "STYLE"))
   )
 )
发表于 2007-2-1 22:12:00 | 显示全部楼层
本帖最后由 作者 于 2007-2-2 13:38:13 编辑

写过一个,但不是反应器类型.需要调用函数名开图.
不够完善,还没时间整,不好意思拿出来.
贴一个以前收集的 (未经测试)
  1. ;|
  2.             ****Readme text to AUTOFONT.LSP Sept. 1, 1996***********
  3. Developed by Peter Allen Landeck.  All rights reserved @ 1996
  4.   100314.1364@compuserve.com
  5. More LSP drafting routines may be found at:
  6.   http://ourworld.compuserve.com/homepages/PLANDECK
  7. Thanks to J. Smith & R. Gesner authors of "Maximizing Autocad Volume II" some of whose subroutines are used in AUTOFONT.LSP.
  8. AUTOFONT.LSP collects and assembles in a separate directory named AUTOFONT all big and small font files required to open a given drawing.  This is usually an .SHX font file.  However, any other referenced font file will be collected.  If no special font files are referenced by the drawing (i.e. only the TXT.SHX font is used) user is prompted that no font files are referenced.  Typically, special font files are used in title blocks and company logos which appear on Autocad drawings.  User may also be prompted regarding named font styles which are not actually files.  These are not assembled in the AUTOFONT directory and the user is prompted accordingly.  It should not be necessary to export these with a drawing to have that drawing successfully opend on another computer system.
  9. The AUTOFONT directory is automatically created in the Autocad path, usually at C:/ACAD/AUTOFONT.  The user is prompted regarding its exact location.  The directory may be deleted after use.  Files in AUTOFONT directory will be overwritten by new font files with the same name when routine is used again.  
  10. This program is useful when transferring Autocad drawings to another computer or computer system which may not have the same set of font files.
  11. LOADING:  To load, make sure the AUTOFONT.LSP is in your ACAD path, usually ACAD/SUPPORT is a good location for LSP files.  From the Autocad command line type (LOAD "AUTOFONT") including the parentheses and quotation marks. After the user prompt type AF to run the routine.  Follow the prompts regarding files to be assembled in AUTOFONT directory.
  12. If you load another drawing or quit the drawing editor you need to manually reload AUTOFONT.LSP as described above.  This process may be automated in your ACAD.LSP file.  See the Autocad reference manual for instructions how to automatically load LSP files when opening a drawing.
  13. AUTOLOCK:  AUTOFONT.LSP is equipped with another LSP program which will limit your use of AUTOFONT.LSP to 10 loadings, afterwhich AUTOFONT.LSP will cease to function.  To obtain a copy with unlimited use send $20 to the following address:
  14.         Peter Landeck
  15.         606 West 49th Terrace
  16.         Kansas City, MO  64112
  17. |;
  18. (setq cm (getvar "cmdecho"))
  19. (setvar "cmdecho" 0)
  20. (while (= nil (findfile "acad.fnt"))
  21.   (setq fp (open "acad.fnt" "w"))
  22.   (princ "3" fp)
  23.   (close fp)
  24.   (command "sh" "attrib acad.fnt +h")
  25. )
  26. (setq fp (open "acad.fnt" "r"))
  27. (setq count (read (read-line fp)))
  28. (close fp)
  29. (command "sh" "attrib acad.fnt +h")
  30. (if (or (= count 3)
  31. (= count 9)
  32. (= count 27)
  33. (= count 81)
  34. (= count 243)
  35. (= count 729)
  36. (= count 2187)
  37. (= count 6561)
  38. (= count 19683)
  39. (= count 59049)
  40. (= count 177147)
  41. (= count 531441)
  42.     )
  43.   (progn
  44.     (if (= count 3)
  45.       (setq alc "1 time.")
  46.     )
  47.     (if (= count 9)
  48.       (setq alc "2 times.")
  49.     )
  50.     (if (= count 81)
  51.       (setq alc "3 times.")
  52.     )
  53.     (if (= count 243)
  54.       (setq alc "4 times.")
  55.     )
  56.     (if (= count 729)
  57.       (setq alc "5 times.")
  58.     )
  59.     (if (= count 2187)
  60.       (setq alc "6 times.")
  61.     )
  62.     (if (= count 6561)
  63.       (setq alc "7 times.")
  64.     )
  65.     (if (= count 19683)
  66.       (setq alc "8 times.")
  67.     )
  68.     (if (= count 59049)
  69.       (setq alc "9 times.")
  70.     )
  71.     (if (= count 177147)
  72.       (setq alc "10 times.")
  73.     )
  74.     (if (= count 531441)
  75.       (setq alc
  76.       "11 (bonus) times.  After this use AUTOFONT.LSP will become inoperative."
  77.       )
  78.     )
  79.     (setq prmt (strcat "\n AUTOFONT.LSP has already been loaded "
  80.          alc
  81.          " \n"
  82.         )
  83.     )
  84.   )
  85.   (setq prmt
  86.   (strcat
  87.     "\n ** LSP program has already been loaded 10 times and is become inoperative ** ;\n"
  88.   )
  89.   )
  90. )
  91. (textpage)
  92. (princ
  93.   (strcat
  94.     "\n This program may be loaded 10 times afterwhich it will become non-functioning. \n"
  95.     prmt
  96.     "\n If you find the AUTOFONT.LSP routine useful send US$20 to the following address \n to receive an unlimited disk copy: \n"
  97.     "\n Peter Landeck 606 West 49th Terrace, KC MO 64112. \n"
  98.     "\n Other LSP routines may be found at:\n http://ourworld.compuserve.com/homepages/PLANDECK \n"
  99.     "\n Touch return key to continue. \n")
  100. )
  101. (getint)
  102. (graphscr)
  103. (setq fp (open "acad.fnt" "r"))
  104. (setq count (read (read-line fp)))
  105. (close fp)
  106. (if (or (= count 3)
  107. (= count 9)
  108. (= count 27)
  109. (= count 81)
  110. (= count 243)
  111. (= count 729)
  112. (= count 2187)
  113. (= count 6561)
  114. (= count 19683)
  115. (= count 59049)
  116. (= count 177147)
  117. (= count 531441)
  118.     )
  119.   (progn
  120.     (command "sh" "attrib acad.fnt -h")
  121.     (setq fp (open "acad.fnt" "w"))
  122.     (princ (* count 3) fp)
  123.     (close fp)
  124.     (command "sh" "attrib acad.fnt +h")
  125.     (defun dxf (code elist) (cdr (assoc code elist)))
  126.     (defun tnlist (tbname / tdata tblist)
  127.       (while (setq tdata (tblnext tbname (not tdata)))
  128. (setq tblist (append tblist (list (dxf 2 tdata))))
  129.       )
  130.     )
  131.     (defun ukword (bit kwd msg def / inp)
  132.       (if (and def (/= def ""))
  133. (setq msg (strcat "\n" msg "<" def ">: ")
  134.        bit (* 2 (fix (/ bit 2)))
  135. )
  136. (if (= " " (substr msg (strlen msg) 1))
  137.    (setq msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": "))
  138.    (setq msg (strcat "\n" msg ": "))
  139. )
  140.       )
  141.       (initget bit kwd)
  142.       (setq inp (getkword msg))
  143.       (if inp
  144. inp
  145. def
  146.       )
  147.     )
  148.     (defun ustr (bit msg def spflag / inp nval)
  149.       (if (and def (/= def ""))
  150. (setq msg (strcat "\n" msg "<" def ">: ")
  151.        inp (getstring msg spflag)
  152.        inp (if (= inp "")
  153.       def
  154.       inp
  155.     )
  156. )
  157. (progn (if (= " " (substr msg (strlen msg) 1))
  158.    (setq
  159.      msg (strcat "\n" (substr msg 1 (1- (strlen msg))) ": ")
  160.    )
  161.    (setq msg (strcat "\n" msg ": "))
  162.         )
  163.         (if (= bit 1)
  164.    (while (= "" (setq inp (getstring msg spflag)))
  165.      (prompt "\nInvalid string.")
  166.    )
  167.    (setq inp (getstring msg spflag))
  168.         )
  169. )
  170.       )
  171.     )
  172.     (prompt "\nType AF to run autofont.LSP \n")
  173.     (defun C:AF (/ cm     l      ll     counts countn countp
  174.    fp test   testl  n      fnts   fntb   fntl
  175.    uk fntf   fntc   countp
  176.   )
  177.       (setq cm    (getvar "cmdecho")
  178.      l    (tnlist "style")
  179.      ll    (length l)
  180.      counts 0
  181.      countn 1
  182.      countp 0
  183.       )
  184.       (setvar "cmdecho" 0)
  185.       (textscr)
  186.       (setq fp (open "$$temp$$" "w"))
  187.       (close fp)
  188.       (setq test (findfile "$$temp$$"))
  189.       (command "files" 3 test "" "")
  190.       (setq testl (strlen test))
  191.       (setq test (substr test 1 (- testl 8)))
  192.       (command "shell" "md AUTOFONT")
  193.       (while (setq n (nth counts l))
  194. (setq counts (+ counts 1))
  195. (setq fnts (dxf 3 (tblsearch "style" n)))
  196. (setq fntb (dxf 4 (tblsearch "style" n)))
  197. (if (not (eq "txt" fnts))
  198.    (setq fntl (append fntl (list (strcase fnts))))
  199. )
  200. (if (not (eq "" fntb))
  201.    (setq fntl (append fntl (list (strcase fntb))))
  202. )
  203.       )
  204.       (foreach x fntl
  205. (if (not (member x fntll))
  206.    (setq fntll (append fntll (list x)))
  207. )
  208.       )
  209.       (foreach x fntll
  210. (progn
  211.    (setq uk (strcat "Include " x " file? "))
  212.    (setq uk (ukword 1 "Y N" uk "Y"))
  213.    (if (eq "Y" uk)
  214.      (progn
  215.        (if (setq fntf (findfile x))
  216.   (progn (setq fntc (strcat test "autofont\" x))
  217.          (command "files" 5 fntf fntc "" "")
  218.          (setq countp (+ countp 1))
  219.   )
  220.   (prompt
  221.     (strcat
  222.       "\n****  "
  223.       x
  224.       "  is not a file or is not found in ACAD path ****\n"
  225.     )
  226.   )
  227.        )
  228.      )
  229.    )
  230. )
  231.       )
  232.       (setq dwgn (strcat (getvar "dwgname") ".dwg"))
  233.       (setq dirn (strcat test "AUTOFONT\"))
  234.       (setvar "cmdecho" cm)
  235.       (prompt (strcat "\n"
  236.         (rtos countp 5)
  237.         " font file(s) referenced by "
  238.         dwgn
  239.         " collected in "
  240.         dirn
  241.         "\n"
  242.        )
  243.       )
  244.       (command pause)
  245.       (graphscr)
  246.       (prompt "\nFor other LSP drafting routines visit web site:")
  247.       (prompt
  248. "\nhttp://ourworld.compuserve.com/homepages/PLANDECK  "
  249.       )
  250.       (princ)
  251.     )
  252.     (setvar "cmdecho" cm)
  253.     (princ)
  254.   )
  255. )
 楼主| 发表于 2007-2-2 11:18:00 | 显示全部楼层

多谢楼上几位答复.

我下载先试一下.谢谢了.

发表于 2008-2-11 16:16:00 | 显示全部楼层
请问有那位测试过了吗?有没有问题??
发表于 2008-11-16 22:58:00 | 显示全部楼层

谁能帮忙把无痕版主发的lsp修改一下,

以方便用自己指定的字体替换未知字体呢?

不懂lsp,请高人帮忙!

发表于 2008-11-18 09:28:00 | 显示全部楼层
给你做一个LISP
(defun c:stt()
 (command"style""standard""宋体"""""""""""))
发表于 2012-4-15 10:02:24 | 显示全部楼层
本帖最后由 【KAIXIN】 于 2012-4-15 10:02 编辑

这里有你要的答案

http://bbs.mjtd.com/thread-93031-1-1.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-5 19:39 , Processed in 0.177042 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表