找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 4156|回复: 21

[讨论]:如何更改多种高度和角度原有文字的宽度比例

[复制链接]
发表于 2003-5-9 10:36:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
如果感到原有DWG文件中的字体宽高比不合适,而文件中的字体又各自具有不同的文字高度和转角需要保持,怎样能更有效地仅仅改变这些文字的宽度比例?比如将宽度比例全部由1.0改为0.7。

    请各位大师发表高见!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-5-9 12:34:40 | 显示全部楼层
不知你用的CAD版本,如果是2000以上可以用属性对话框加过滤一次搞定
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-9 13:02:29 | 显示全部楼层
以前在R14中的附加程序(Bonus)中有一个chtext.lsp程序,其命令为cht,可以解决这个问题,它还可以进行文本的替换等。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-9 17:33:05 | 显示全部楼层
对字体的宽高比进行设置可以
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-5-12 22:18:29 | 显示全部楼层
最初由 XLLI8704 发布
[B]不知你用的CAD版本,如果是2000以上可以用属性对话框加过滤一次搞定 [/B]



谢谢!
我用的是2002版。但不知你说的“用属性对话框加过滤一次搞定”怎么做,盼赐教。
这个问题可能困惑许多CAD爱好者,也替大家谢谢你!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-12 22:37:55 | 显示全部楼层
这样如何:
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-12 23:38:07 | 显示全部楼层
个人觉得,首先用style设置一个文字样式,觉得不合适时,再使用style命令,在文字样式对话框里面更改文字的高宽比,概念更清晰!
        并且,style命令还可以改变文字的字体形式,配合rename命令,当字体改变时,再改变文字样式的名字,岂不更妙?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-5-15 11:57:14 | 显示全部楼层
改变单串文字的宽度比例,CAD应用者可能都掌握。
关键是想修改一个已经做好的DWG文件中的许许多多各自具有不同高度和转角的文字的宽度比例。

在文字样式中修改不会对图中原有文字宽度比例起作用。

而用属性匹配,又会改变各文字分别具有的高度和转角属性。


请各位真正大师级用户发表高见!



真诚希望XLLI8704兄和zhynt斑竹详细说明一下你们的做法。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-15 12:23:36 | 显示全部楼层
用ahlzl 提出的方法即可解决,虽然他的演示不如你说的复杂,但是操作是一样的,只要过滤出所有文字,指定一个公共的宽度系数(如0.7)即可
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-15 15:15:21 | 显示全部楼层
我把这个过程再做一遍(我的第一次Flash cam演示,弄得不好请包涵)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-15 18:49:58 | 显示全部楼层
最初由 zhynt 发布
[B]以前在R14中的附加程序(Bonus)中有一个chtext.lsp程序,其命令为cht,可以解决这个问题,它还可以进行文本的替换等。 [/B]
是这个吗?
  1. ; Next available MSG number is   83
  2. ; MODULE_ID CHTEXT_LSP_
  3. ; $Header: /sedona/develop/support/chtext.lsp 8     4/29/97 5:35p Derrl $
  4. ;;;
  5. ;;;    CHTEXT.lsp - change text
  6. ;;;
  7. ;;;    Copyright 1997 by Autodesk, Inc.
  8. ;;;
  9. ;;;    Permission to use, copy, modify, and distribute this software
  10. ;;;    for any purpose and without fee is hereby granted, provided
  11. ;;;    that the above copyright notice appears in all copies and
  12. ;;;    that both that copyright notice and the limited warranty and
  13. ;;;    restricted rights notice below appear in all supporting
  14. ;;;    documentation.
  15. ;;;
  16. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  17. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  18. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  19. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  20. ;;;    UNINTERRUPTED OR ERROR FREE.
  21. ;;;
  22. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  23. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  24. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  25. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  26. ;;;  
  27. ;;;--------------------------------------------------------------------------;
  28. ;;; DESCRIPTION
  29. ;;;   This is a "text processor" which operates in a global manner
  30. ;;;   on all of the text entities that the user selects; i.e., the
  31. ;;;   Height, Justification, Location, Rotation, Style, Text, and
  32. ;;;   Width can all be changed globally or individually, and the
  33. ;;;   range of values for a given parameter can be listed.
  34. ;;;   
  35. ;;;   The command is called with CHT from the command line at which
  36. ;;;   time the user is asked to select the objects to change.
  37. ;;;   
  38. ;;;     Select text to change.
  39. ;;;     Select objects:
  40. ;;;  
  41. ;;;   If nothing is selected the message "ERROR: Nothing selected."
  42. ;;;   is displayed and the command is terminated.  If more than 25
  43. ;;;   entities are selected the following message is displayed while
  44. ;;;   the text entities are sorted out from the non-text entities.
  45. ;;;   A count of the text entities found is then displayed.
  46. ;;;   
  47. ;;;     Verifying the selected entities...
  48. ;;;     nnn  text entities found.
  49. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  50. ;;;   
  51. ;;;   A typical example of the prompts you may encounter follows:
  52. ;;;   
  53. ;;;   If you select a single text entity to change and ask to change
  54. ;;;   the height, the prompt looks like this:
  55. ;;;   
  56. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  57. ;;;     New text height for text entity. <0.08750000>:
  58. ;;;   
  59. ;;;   If you select more than one text entity to change and ask to change
  60. ;;;   the height, the prompt looks like this:
  61. ;;;   
  62. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  63. ;;;     Individual/List/<New height for all entities>:
  64. ;;;   
  65. ;;;   Typing "L" at this prompt returns a prompt showing you the range of
  66. ;;;   values that you are using for your text.
  67. ;;;   
  68. ;;;     Height -- Min: 0.05000000  Max: 0.10000000  Ave: 0.08392857
  69. ;;;   
  70. ;;;   Typing "I" at this prompt puts you in a loop, processing the text
  71. ;;;   entities you have selected one at a time, and giving the same prompt
  72. ;;;   you get for a single text entity shown above.
  73. ;;;   
  74. ;;;   Pressing ENTER at this point puts you back at the Command: prompt.
  75. ;;;   Selecting any of the other options allows you to change the text
  76. ;;;   entities selected.
  77. ;;;   
  78. ;;;---------------------------------------------------------------------------;

  79. (defun cht_Main ( / sset opt ssl nsset temp unctr ct_ver sslen style hgt rot
  80.                     txt ent loc loc1 just-idx justp justq orthom
  81.                     cht_ErrorHandler cht_OrgError cht_OrgCmdecho
  82.                     cht_OrgTexteval cht_OrgHighlight)

  83.   ;; Reset if changed
  84.   (setq ct_ver "2.00")

  85.   ;; Internal error handler defined locally
  86.   (defun cht_ErrorHandler (s)
  87.     (if (/= s "函数已取消")
  88.       (if (= s "quit / exit abort")
  89.         (princ)
  90.         (princ (strcat "\n错误: " s))
  91.       )
  92.     )
  93.     (eval (read U:E))
  94.     ;;  Reset original error handler if there
  95.     (if cht_OrgError (setq *error* cht_OrgError))
  96.     (if temp (redraw temp 1))
  97.     (ai_undo_off) ;; restore undo state
  98.     (if cht_OrgCmdecho (setvar "cmdecho" cht_OrgCmdecho))
  99.     (if cht_OrgTexteval (setvar "texteval" cht_OrgTexteval))
  100.     (if cht_OrgHighlight (setvar "highlight" cht_OrgHighlight))
  101.     (princ)
  102.   )

  103.   ;; Set error handler
  104.   (if *error*
  105.     (setq cht_OrgError *error*
  106.           *error* cht_ErrorHandler)
  107.     (setq *error* cht_ErrorHandler)
  108.   )

  109.   ;; Set undo groups and ends with (eval(read U:G)) or (eval(read U:E))
  110.   (setq U:G "(command "_.undo" "_group")"
  111.         U:E "(command "_.undo" "_en")"
  112.   )
  113.   
  114.   (ai_undo_on)       ;; enable undo
  115.   
  116.   (setq cht_OrgCmdecho (getvar "cmdecho"))
  117.   (setq cht_OrgHighlight (getvar "highlight"))
  118.   (setvar "cmdecho" 0)
  119.   
  120.   (princ (strcat "\n修改文字,Version "
  121.                  ct_ver
  122.                  ", 版权(c) 1997 Autodesk, Inc."))
  123.   (prompt "\n选择要修改的注释对象。")
  124.   (setq sset (ai_aselect))
  125.   (if (null sset)
  126.     (progn
  127.       (princ "\n未选择对象。")
  128.       (exit)
  129.     )
  130.   )
  131.   ;; Validate selection set
  132.   (setq ssl   (sslength sset)
  133.         nsset (ssadd))
  134.   (if (> ssl 25)
  135.     (princ "\n验证选择的对象...")
  136.   )
  137.   (while (> ssl 0)
  138.     (setq temp (ssname sset (setq ssl (1- ssl))))
  139.     (if (or
  140.           (= (cdr (assoc 0 (entget temp))) "TEXT")
  141.           (= (cdr (assoc 0 (entget temp))) "ATTDEF")
  142.           (= (cdr (assoc 0 (entget temp))) "MTEXT")
  143.         )
  144.       (ssadd temp nsset)
  145.     )
  146.   )
  147.   (setq ssl (sslength nsset)
  148.         sset nsset
  149.         unctr 0
  150.   )
  151.   (print ssl)
  152.   (princ "已找到注释对象。")

  153.   ;; Main loop
  154.   (setq opt T)
  155.   (while (and opt (> ssl 0))
  156.     (setq unctr (1+ unctr))
  157.     (command "_.UNDO" "_GROUP")
  158.     (initget "Location Justification Style Height Rotation Width Text Undo")
  159.     (setq opt (getkword
  160.       "\n高度(H)/调整(J)/位置(L)/旋转(R)/样式(S)/文字(T)/放弃(U)/宽度(W): "))
  161.     (if opt
  162.       (cond
  163.         ((= opt "Undo")
  164.           (cht_Undo)
  165.         )
  166.         ((= opt "Location")
  167.           (cht_Location)
  168.         )
  169.         ((= opt "Justification")
  170.           (cht_Justification)
  171.         )
  172.         ((= opt "Style")
  173.           (cht_Property "Style"    "新样式名"      7) )
  174.         ((= opt "Height")
  175.           (cht_Property "Height"   "新高度"         40) )
  176.         ((= opt "Rotation")
  177.           (cht_Property "Rotation" "新旋转角度" 50) )
  178.         ((= opt "Width")
  179.           (cht_Property "Width"    "新宽度因子"   41) )
  180.         ((= opt "Text")
  181.           (cht_Text)
  182.         )
  183.       )
  184.       (setq opt nil)
  185.     )
  186.     (command "_.UNDO" "_END")
  187.   )

  188.   ;; Restore
  189.   (if cht_OrgError (setq *error* cht_OrgError))
  190.   (eval (read U:E))
  191.   (ai_undo_off) ;; restore undo state
  192.   (if cht_OrgTexteval (setvar "texteval" cht_OrgTexteval))
  193.   (if cht_OrgHighlight (setvar "highlight" cht_OrgHighlight))
  194.   (if cht_OrgCmdecho (setvar "cmdecho" cht_OrgCmdecho))
  195.   (princ)
  196. )

  197. ;;; Undo an entry
  198. (defun cht_Undo ()
  199.   (if (> unctr 1)
  200.     (progn
  201.       (command "_.UNDO" "_END")
  202.       (command "_.UNDO" "2")
  203.       (setq unctr (- unctr 2))
  204.     )
  205.     (progn
  206.       (princ "\n无可放弃的操作。")
  207.       (setq unctr (- unctr 1))
  208.     )
  209.   )
  210. )

  211. ;;; Change the location of an entry
  212. (defun cht_Location ()
  213.   (setq sslen (sslength sset)
  214.         style ""
  215.         hgt   ""
  216.         rot   ""
  217.         txt   ""
  218.   )
  219.   (command "_.CHANGE" sset "" "")
  220.   (while (> sslen 0)
  221.     (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  222.           opt (list (cadr (assoc 11 ent))
  223.                     (caddr (assoc 11 ent))
  224.                     (cadddr (assoc 11 ent)))
  225.     )
  226.     (prompt "\n新文字位置: ")
  227.     (command pause)
  228.     (if (null loc)
  229.       (setq loc opt)
  230.     )
  231.     (command style hgt rot txt)
  232.   )
  233.   (command)
  234. )

  235. ;;; Change the justification of an entry
  236. (defun cht_Justification ()
  237.   (initget "TL TC TR ML MC MR BL BC BR Align Center Fit Left Middle Right ?")
  238.   (setq sslen (sslength sset))
  239.   (setq justp (getkword "\n对齐(A)/拟合(F)/中心(C)/向左(L)/中央(M)/向右(R)/左上(TL)/中上(TC)/右上(TR)/左中(ML)/正中(MC)/右中(MR)/左下(BL)/中下(BC)/右下(BR)/<?>: "))
  240.   (cond
  241.     ((= justp "Left")    (setq justp 0 justq 0 just-idx 4) )
  242.     ((= justp "Center")  (setq justp 1 justq 0 just-idx 5) )
  243.     ((= justp "Right")   (setq justp 2 justq 0 just-idx 6) )
  244.     ((= justp "Align")   (setq justp 3 justq 0 just-idx 1) )
  245.     ((= justp "Fit")     (setq justp 5 justq 0 just-idx 1) )
  246.     ((= justp "TL")      (setq justp 0 justq 3 just-idx 1) )
  247.     ((= justp "TC")      (setq justp 1 justq 3 just-idx 2) )
  248.     ((= justp "TR")      (setq justp 2 justq 3 just-idx 3) )
  249.     ((= justp "ML")      (setq justp 0 justq 2 just-idx 4) )
  250.     ((= justp "Middle")  (setq justp 4 justq 0 just-idx 5) )
  251.     ((= justp "MC")      (setq justp 1 justq 2 just-idx 5) )
  252.     ((= justp "MR")      (setq justp 2 justq 2 just-idx 6) )
  253.     ((= justp "BL")      (setq justp 0 justq 1 just-idx 7) )
  254.     ((= justp "BC")      (setq justp 1 justq 1 just-idx 8) )
  255.     ((= justp "BR")      (setq justp 2 justq 1 just-idx 9) )
  256.     ((= justp "?")       (setq justp nil)       )
  257.     (T                   (setq justp nil)       )
  258.   )   
  259.   (if justp
  260.     (progn ;; Process them...
  261.       (while (> sslen 0)
  262.         (setq ent (entget (ssname sset (setq sslen (1- sslen)))))
  263.         (cond
  264.           ((= (cdr (assoc 0 ent)) "MTEXT")
  265.             (setq ent (subst (cons 71 just-idx) (assoc 71 ent) ent))
  266.           )
  267.           ((= (cdr (assoc 0 ent)) "TEXT")
  268.             (setq ent (subst (cons 72 justp) (assoc 72 ent) ent)
  269.                   opt (trans (list (cadr (assoc 11 ent))
  270.                                    (caddr (assoc 11 ent))
  271.                                    (cadddr (assoc 11 ent)))
  272.                              (cdr (assoc -1 ent)) ;; from ECS
  273.                              1)               ;; to current UCS
  274.             )
  275.             (setq ent (subst (cons 73 justq) (assoc 73 ent) ent))
  276.             (cond
  277.               ((or (= justp 3) (= justp 5))
  278.                 (prompt "\n新文字对齐点: ")
  279.                 (if (= (setq orthom (getvar "orthomode")) 1)
  280.                   (setvar "orthomode" 0)
  281.                 )
  282.                 (redraw (cdr (assoc -1 ent)) 3)
  283.                 (initget 1)
  284.                 (setq loc (getpoint))
  285.                 (initget 1)
  286.                 (setq loc1 (getpoint loc))
  287.                 (redraw (cdr (assoc -1 ent)) 1)
  288.                 (setvar "orthomode" orthom)
  289.                 (setq ent (subst (cons 10 loc) (assoc 10 ent) ent))
  290.                 (setq ent (subst (cons 11 loc1) (assoc 11 ent) ent))
  291.               )
  292.               ((or (/= justp 0) (/= justq 0))
  293.                 (redraw (cdr (assoc -1 ent)) 3)
  294.                 (prompt "\n新文字位置: ")
  295.                 (if (= (setq orthom (getvar "orthomode")) 1)
  296.                   (setvar "orthomode" 0)
  297.                 )
  298.                 (setq loc (getpoint opt))
  299.                 (setvar "orthomode" orthom)
  300.                 (redraw (cdr (assoc -1 ent)) 1)
  301.                 (if (null loc)
  302.                   (setq loc opt)
  303.                   (setq loc (trans loc 1 (cdr (assoc -1 ent))))
  304.                 )
  305.                 (setq ent (subst (cons 11 loc) (assoc 11 ent) ent))
  306.               )
  307.             )
  308.           )
  309.         )
  310.         (entmod ent)
  311.       )
  312.     )
  313.     (progn        ;; otherwise list options
  314.       (textpage)
  315.       (princ "\n对齐方式选项: \n")
  316.       (princ "\t  左上   中上    右上\n")
  317.       (princ "\t  左中   正中    右中\n")
  318.       (princ "\t  左下   中下    右下\n")
  319.       (princ "\t 左     中心    右\n")
  320.       (princ "\t对齐    中央    调整\n")
  321.       (princ "\n按 ENTER 键继续: ")
  322.       (grread)
  323.       (princ "\r                                                            ")
  324.       (graphscr)
  325.     )
  326.   )
  327.   (command)
  328. )

  329. ;;; Change the text of an object
  330. (defun cht_Text ( / ans)
  331.   (setq sslen (sslength sset))
  332.   (initget "Globally Individually Retype")
  333.   (setq ans (getkword
  334.     "\n查找并替换文字。  单个(I)/重新键入(R)/<全局(G)>: "))
  335.   (setq cht_OrgTexteval (getvar "texteval"))
  336.   (setvar "texteval" 1)
  337.   (cond
  338.     ((= ans "Individually")
  339.       (progn
  340.         (initget "Yes No")
  341.         (setq ans (getkword "\n在对话框中编辑文字?<是(Y)>: "))
  342.       )
  343.   
  344.       (while (> sslen 0)
  345.         (redraw (setq sn (ssname sset (setq sslen (1- sslen)))) 3)
  346.         (setq ss (ssadd))
  347.         (ssadd (ssname sset sslen) ss)
  348.         (if (= ans "No")
  349.           (cht_Edit ss)
  350.           (command "_.DDEDIT" sn "")
  351.         )
  352.         (redraw sn 1)
  353.       )
  354.     )
  355.     ((= ans "Retype")
  356.       (while (> sslen 0)
  357.         (setq ent (entget (ssname sset (setq sslen (1- sslen)))))
  358.         (redraw (cdr (assoc -1 ent)) 3)
  359.         (prompt (strcat "\n原文字: " (cdr (assoc 1 ent))))
  360.         (setq nt (getstring  T "\n新文字: "))
  361.         (redraw (cdr (assoc -1 ent)) 1)
  362.         (if (> (strlen nt) 0)
  363.           (entmod (subst (cons 1 nt) (assoc 1 ent) ent))
  364.         )
  365.       )
  366.     )
  367.     (T
  368.       (cht_Edit sset)   ;; Change all
  369.     )
  370.   )
  371.   (setvar "texteval" cht_OrgTexteval)
  372. )

  373. ;;; The old CHGTEXT command - rudimentary text editor
  374. (defun C:CHGTEXT () (cht_Edit nil))

  375. (defun cht_Edit (objs / last_o tot_o ent o_str n_str st s_temp
  376.                        n_slen o_slen si chf chm cont ans class)
  377.   ;; Select objects if running standalone
  378.   (if (null objs)
  379.     (setq objs (ssget))
  380.   )
  381.   (setq chm 0)
  382.   (if objs
  383.     (progn                   ;; If any objects selected
  384.       (if (= (type objs) 'ENAME)
  385.         (progn
  386.           (setq ent (entget objs))
  387.           (princ (strcat "\n现有字符串: " (cdr (assoc 1 ent))))
  388.         )
  389.         (if (= (sslength objs) 1)
  390.           (progn
  391.             (setq ent (entget (ssname objs 0)))
  392.             (princ (strcat "\n现有字符串: " (cdr (assoc 1 ent))))
  393.           )
  394.         )
  395.       )
  396.       (setq o_str (getstring "\n匹配字符串: " t))
  397.       (setq o_slen (strlen o_str))
  398.       (if (/= o_slen 0)
  399.         (progn
  400.           (setq n_str (getstring "\n新字符串: " t))
  401.           (setq n_slen (strlen n_str))
  402.           (setq last_o 0
  403.                 tot_o  (if (= (type objs) 'ENAME)
  404.                          1
  405.                          (sslength objs)
  406.                        )
  407.           )
  408.           ;; For each selected object...
  409.           (while (< last_o tot_o)
  410.             (setq class (cdr (assoc 0 (setq ent (entget (ssname objs last_o))))))
  411.             (if (or (= "TEXT" class)
  412.                     (= "MTEXT" class) )
  413.               (progn
  414.                 (setq chf nil si 1)
  415.                 (setq s_temp (cdr (assoc 1 ent)))
  416.                 (while (= o_slen (strlen (setq st (substr s_temp si o_slen))))
  417.                   (if (= st o_str)
  418.                     (progn
  419.                       (setq s_temp (strcat
  420.                                      (if (> si 1)
  421.                                        (substr s_temp 1 (1- si))
  422.                                        ""
  423.                                      )
  424.                                      n_str
  425.                                      (substr s_temp (+ si o_slen))
  426.                                    )
  427.                       )
  428.                       (setq chf t)    ;; Found old string
  429.                       (setq si (+ si n_slen))
  430.                     )
  431.                     (setq si (1+ si))
  432.                   )
  433.                 )
  434.                 (if chf
  435.                   (progn              ;; Substitute new string for old
  436.                     ;; Modify the TEXT entity
  437.                     (entmod (subst (cons 1 s_temp) (assoc 1 ent) ent))
  438.                     (setq chm (1+ chm))
  439.                   )
  440.                 )
  441.               )
  442.             )
  443.             (setq last_o (1+ last_o))
  444.           )
  445.         )
  446.         ;; else go on to the next line...
  447.       )
  448.     )
  449.   )
  450.   (if (/= (type objs) 'ENAME)
  451.     ;; Print total lines changed
  452.     (if (/= (sslength objs) 1)
  453.       (princ (strcat (rtos chm 2 0) " 文字行已修改。"))
  454.     )
  455.   )
  456.   (terpri)
  457. )

  458. ;;; Main procedure for manipulating text entities
  459. (defun cht_Property (typ prmpt fld / temp ow nw ent tw sty w hw lw
  460.                               sslen n sn ssl)
  461.   (if (= (sslength sset) 1)           ;; Special case if there is only
  462.                                       ;; one entity selected
  463.     ;; Process one entity.
  464.     (cht_ProcessOne)
  465.     ;; Else
  466.     (progn
  467.       ;; Set prompt string.
  468.       (cht_SetPrompt)
  469.       (if (= nw "List")
  470.         ;; Process List request.
  471.         (cht_ProcessList)
  472.         (if (= nw "Individual")
  473.           ;; Process Individual request.
  474.           (cht_ProcessIndividual)
  475.           (if (= nw "Select")
  476.             ;; Process Select request.
  477.             (cht_ProcessSelect)
  478.             ;; Else
  479.             (progn
  480.               (if (= typ "Rotation")
  481.                 (setq nw (* (/ nw 180.0) pi))
  482.               )
  483.               (if (= (type nw) 'STR)
  484.                 (if (not (tblsearch "style" nw))
  485.                   (progn
  486.                     (princ (strcat nw ": 未找到样式。"))
  487.                   )
  488.                   (cht_ProcessAll)
  489.                 )
  490.                 (cht_ProcessAll)
  491.               )
  492.             )
  493.           )
  494.         )
  495.       )
  496.     )
  497.   )
  498. )

  499. ;;; Change all of the entities in the selection set
  500. (defun cht_ProcessAll (/ hl temp)
  501.   (setq sslen (sslength sset))
  502.   (setq hl (getvar "highlight"))
  503.   (setvar "highlight" 0)
  504.   (while (> sslen 0)
  505.     (setq temp (ssname sset (setq sslen (1- sslen))))
  506.     (entmod (subst (cons fld nw)
  507.                    (assoc fld (setq ent (entget temp)))
  508.                    ent ) )
  509.   )
  510.   (setvar "highlight" hl)
  511. )

  512. ;;; Change one text entity
  513. (defun cht_ProcessOne ()
  514.   (setq temp (ssname sset 0))
  515.   (setq ow (cdr (assoc fld (entget temp))))
  516.   (if (= opt "Rotation")
  517.     (setq ow (/ (* ow 180.0) pi))
  518.   )
  519.   (redraw (cdr (assoc -1 (entget temp))) 3)
  520.   (initget 0)
  521.   (if (= opt "Style")
  522.     (setq nw (getstring (strcat prmpt " <" ow ">: ")))
  523.     (setq nw (getreal (strcat prmpt " <" (rtos ow 2) ">: ")))
  524.   )
  525.   (if (or (= nw "") (= nw nil))
  526.     (setq nw ow)
  527.   )
  528.   (redraw (cdr (assoc -1 (entget temp))) 1)
  529.   (if (= opt "Rotation")
  530.     (setq nw (* (/ nw 180.0) pi))
  531.   )
  532.   (if (= opt "Style")
  533.     (if (null (tblsearch "style" nw))
  534.       (princ (strcat nw ": 未找到样式。"))
  535.       (entmod (subst (cons fld nw)
  536.                      (assoc fld (setq ent (entget temp)))
  537.                      ent
  538.               )
  539.       )
  540.     )
  541.     (entmod (subst (cons fld nw)
  542.                    (assoc fld (setq ent (entget temp)))
  543.                    ent
  544.             )
  545.     )
  546.   )
  547. )

  548. ;;; Set the prompt string
  549. (defun cht_SetPrompt ()
  550.   (if (= typ "Style")
  551.     (progn
  552.       (initget "Individual List New Select ")
  553.       (setq nw (getkword (strcat "\n单个(I)/列表(L)/选择样式(S)/<"
  554.                                  prmpt
  555.                                  " 为所有文字对象" ">: ")))
  556.       (if (or (= nw "") (= nw nil) (= nw "输入"))
  557.         (setq nw (getstring (strcat prmpt
  558.                                     " 为所有文字对象" ": ")))
  559.       )
  560.     )
  561.     (progn
  562.       (initget "List Individual" 1)
  563.       (setq nw (getreal (strcat "\n单个(I)/列表(L)/<"
  564.                                  prmpt
  565.                                  " 为所有文字对象" ">: ")))
  566.     )
  567.   )
  568. )

  569. ;;; Process List request
  570. (defun cht_ProcessList ()
  571.   (setq unctr (1- unctr))
  572.   (setq sslen (sslength sset))
  573.   (setq tw 0)
  574.   (while (> sslen 0)
  575.     (setq temp (ssname sset (setq sslen (1- sslen))))
  576.     (if (= typ "Style")
  577.       (progn
  578.         (if (= tw 0)
  579.           (setq tw (list (cdr (assoc fld (entget temp)))))
  580.           (progn
  581.             (setq sty (cdr (assoc fld (entget temp))))
  582.             (if (not (member sty tw))
  583.               (setq tw (append tw (list sty)))
  584.             )
  585.           )
  586.         )
  587.       )
  588.       (progn
  589.         (setq tw (+ tw (setq w (cdr (assoc fld (entget temp))))))
  590.         (if (= (sslength sset) (1+ sslen)) (setq lw w hw w))
  591.         (if (< hw w) (setq hw w))
  592.         (if (> lw w) (setq lw w))
  593.       )
  594.     )
  595.   )
  596.   (if (= typ "Rotation")
  597.     (setq tw (* (/ tw pi) 180.0)
  598.           lw (* (/ lw pi) 180.0)
  599.           hw (* (/ hw pi) 180.0))
  600.   )
  601.   (if (= typ "Style")
  602.     (progn
  603.       (princ (strcat "\n" typ " -- "))
  604.       (princ tw)
  605.     )
  606.     (princ (strcat "\n" typ
  607.              " -- 最小: " (rtos lw 2)
  608.              "\t 最大: " (rtos hw 2)
  609.              "\t 平均: " (rtos (/ tw (sslength sset)) 2) ) )
  610.   )
  611. )

  612. ;;; Process Individual request
  613. (defun cht_ProcessIndividual ()
  614.   (setq sslen (sslength sset))
  615.   (while (> sslen 0)
  616.     (setq temp (ssname sset (setq sslen (1- sslen))))
  617.     (setq ow (cdr (assoc fld (entget temp))))
  618.     (if (= typ "Rotation")
  619.       (setq ow (/ (* ow 180.0) pi))
  620.     )
  621.     (initget 0)
  622.     (redraw (cdr (assoc -1 (entget temp))) 3)
  623.     (if (= typ "Style")
  624.       (progn
  625.         (setq nw (getstring (strcat "\n" prmpt " <" ow ">: ")))
  626.       )
  627.       (progn
  628.         (setq nw (getreal (strcat "\n" prmpt " <" (rtos ow 2) ">: ")))
  629.       )
  630.     )
  631.     (if (or (= nw "") (= nw nil))
  632.       (setq nw ow)
  633.     )
  634.     (if (= typ "Rotation")
  635.       (setq nw (* (/ nw 180.0) pi))
  636.     )
  637.     (entmod (subst (cons fld nw)
  638.                    (assoc fld (setq ent (entget temp)))
  639.                    ent
  640.             )
  641.     )
  642.     (redraw (cdr (assoc -1 (entget temp))) 1)
  643.   )
  644. )

  645. ;;; Process the Select option
  646. (defun cht_ProcessSelect ()
  647.   (princ "\n给出搜索样式名?<*>: ")
  648.   (setq sn  (xstrcase (getstring))
  649.         n   -1
  650.         nsset (ssadd)
  651.         ssl (1- (sslength sset))
  652.         )
  653.   (if (or (= sn "*") (null sn) (= sn ""))
  654.     (setq nsset sset sn "*")
  655.     (while (and sn (< n ssl))
  656.       (setq temp (ssname sset (setq n (1+ n))))
  657.       (if (= (cdr (assoc 7 (entget temp))) sn)
  658.         (ssadd temp nsset)
  659.       )
  660.     )
  661.   )

  662.   (princ (strcat "\n样式: " sn))
  663.   (print (setq ssl (sslength nsset)))
  664.   (princ " 个对象已找到。")
  665. )

  666. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  667. ;;; and then try to load it.  If it can't be found or can't be
  668. ;;; loaded, then abort the loading of this file immediately.
  669. (cond
  670.   ((and ai_dcl (listp ai_dcl)))                ; it's already loaded.
  671.   ((not (findfile "ai_utils.lsp"))                ; find it
  672.     (ai_abort "CHT" nil)
  673.   )
  674.   ((eq "failed" (load "ai_utils" "failed"))        ; load it
  675.     (ai_abort "CHT" nil)
  676.   )
  677. )

  678. ;;; If we get this far, then AI_UTILS.LSP is loaded and it can
  679. ;;; be assumed that all functions defined therein are available.

  680. ;;; Next, check to see if ACADAPP.EXP has been xloaded, and abort
  681. ;;; if the file can't be found or xloaded.  Note that AI_ACADAPP
  682. ;;; does not abort the running application itself (so that it can
  683. ;;; also be called from within the command without also stopping
  684. ;;; an AutoCAD command currently in progress).
  685. (if (not (ai_acadapp)) (ai_abort "CHT" nil))

  686. ;;; The C: function definition
  687. (defun c:cht () (cht_Main))
  688. (princ "\n\t已加载 CHT 命令。")
  689. (princ)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-5-20 11:53:07 | 显示全部楼层
请各位先弄清问题的关键所在(我在把它复述一遍):

如果感到原有DWG文件中的字体宽高比不合适,而文件中的字体又各自具有不同的文字高度和转角需要保持,怎样能更有效地仅仅改变这些文字的宽度比例?比如将宽度比例全部由1.0改为0.7。

改变单串文字的宽度比例,CAD应用者可能都掌握。
关键是想修改一个已经做好的DWG文件中的许许多多各自具有不同高度和转角的文字的宽度比例。
在文字样式中修改不会对图中原有文字宽度比例起作用。
而用属性匹配,又会改变各文字分别具有的高度和转角属性。

另外,当过滤出同一种属性的许多文字时,是可以改变其宽高比属性的,单当过滤出的文字具有不同属性时,更改特性的命令对话框中就没有宽度比例这一项了,也就是说不能再用这一方法调整其宽高比属性了。

请各位真正大师级用户发表高见!



真诚希望XLLI8704兄和zhynt斑竹详细说明一下你们的做法。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-20 16:17:03 | 显示全部楼层
我不是大师,只能提供一点参考

如果文字全为单行文字[/COLOR] ,ahlzl的方法是可以的。XLLI8704说的就是这个方法,zhynt斑竹说的CHT的功能也可以在这个“特性”窗口中实现。

如果包含多行文字[/COLOR] ,此法不通,多行文字只能修改样式(注:单行文字修改样式宽度比例,对已生成的文字的宽度比例无效,多行文字可以的)。

如果能将多行文字进行分解,也变成了单行文字……

演示中除了最下面一行为多行文字,其余均为单行文字
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-20 16:28:38 | 显示全部楼层
修改样式……
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-5-20 22:10:20 | 显示全部楼层
这个问题需要大师级的来解决吗?
提供解决方案的都是大师级的呀!
并且我认为他们解答的很好!:)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-11-20 09:31 , Processed in 0.508048 second(s), 61 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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