乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 68|回复: 1

[编程交流] 用于更改文本par的旧lisp

[复制链接]

9

主题

49

帖子

41

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-5 22:14:05 | 显示全部楼层 |阅读模式
我只是因为日期(1990年3月9日)才想发布它,但经过快速测试,我发现它非常有用,在autocad 2012中可以开箱即用,尽管它的年龄几乎是四分之一世纪!
  1. ;;;   CHTEXT.lsp
  2. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  3. ;;;  
  4. ;;;   Permission to use, copy, modify, and distribute this software and its
  5. ;;;   documentation for any purpose and without fee is hereby granted.  
  6. ;;;
  7. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
  8. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
  9. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  10. ;;;
  11. ;;;   by Jan S. Yoder
  12. ;;;   09 March  1990
  13. ;;;
  14. ;;;--------------------------------------------------------------------------;
  15. ;;; DESCRIPTION
  16. ;;;   This is a "text processor" which operates in a global manner
  17. ;;;   on all of the text entities that the user selects; i.e., the
  18. ;;;   Height, Justification, Location, Rotation, Style, Text, and
  19. ;;;   Width can all be changed globally or individually, and the
  20. ;;;   range of values for a given parameter can be listed.
  21. ;;;   
  22. ;;;   The command is called with CHT from the command line at which
  23. ;;;   time the user is asked to select the objects to change.
  24. ;;;   
  25. ;;;     Select text to change.
  26. ;;;     Select objects:
  27. ;;;  
  28. ;;;   If nothing is selected the message "ERROR: Nothing selected."
  29. ;;;   is displayed and the command is terminated.  If more than 25
  30. ;;;   entities are selected the following message is displayed while
  31. ;;;   the text entities are sorted out from the non-text entities.
  32. ;;;   A count of the text entities found is then displayed.
  33. ;;;   
  34. ;;;     Verifying the selected entities -- please wait.
  35. ;;;     nnn  text entities found.
  36. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  37. ;;;   
  38. ;;;   A typical example of the prompts you may encounter follows:
  39. ;;;   
  40. ;;;   If you select a single text entity to change and ask to change
  41. ;;;   the height, the prompt looks like this:
  42. ;;;   
  43. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  44. ;;;     New text height for text entity. <0.08750000>:
  45. ;;;   
  46. ;;;   If you select more than one text entity to change and ask to change
  47. ;;;   the height, the prompt looks like this:
  48. ;;;   
  49. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  50. ;;;     Individual/List/<New height for all entities>:
  51. ;;;   
  52. ;;;   Typing "L" at this prompt returns a prompt showing you the range of
  53. ;;;   values that you are using for your text.
  54. ;;;   
  55. ;;;     Height -- Min: 0.05000000  Max: 0.10000000  Ave: 0.08392857
  56. ;;;   
  57. ;;;   Typing "I" at this prompt puts you in a loop, processing the text
  58. ;;;   entities you have selected one at a time, and giving the same prompt
  59. ;;;   you get for a single text entity shown above.
  60. ;;;   
  61. ;;;   Pressing RETURN at this point puts you back at the Command: prompt.
  62. ;;;   Selecting any of the other options allows you to change the text
  63. ;;;   entities selected.
  64. ;;;   
  65. ;;;   All of the Release 11 text alignment options have been supported.  
  66. ;;;   This is based on the system variable "DIMCLRD" being present.  
  67. ;;;   If it is not present, then only the  Release 10 alignment options
  68. ;;;   are allowed.
  69. ;;;   
  70. ;;;---------------------------------------------------------------------------;
  71. ;;;
  72. ;;; Main function -- no arguments
  73. ;;;
  74. (defun chtxt (/ sset opt ssl nsset temp unctr
  75.                sslen style hgt rot txt ent cht_oc
  76.                loc loc1 justp justq orthom )
  77. (setq pt_ver "1.00")                ; Reset this local if you make a change.
  78. ;;
  79. ;; Internal error handler defined locally
  80. ;;
  81. (defun cht_er (s)                   ; If an error (such as CTRL-C) occurs
  82.                                      ; while this command is active...
  83.    (if (/= s "Function cancelled")
  84.      (if (= s "quit / exit abort")
  85.        (princ)
  86.        (princ (strcat "\nError: " s))
  87.      )
  88.    )
  89.    (eval(read U:E))
  90.    (if cht_oe                        ; If an old error routine exists
  91.      (setq *error* cht_oe)           ; then, reset it
  92.    )
  93.    (if cht_oc (setvar "cmdecho" cht_oc)) ; Reset command echoing
  94.    (if cht_ot (setvar "texteval" cht_ot))
  95.    (if cht_oh (setvar "highlight" cht_oh))
  96.    (princ)
  97. )
  98. ;;
  99. ;; Body of function
  100. ;;
  101. (if *error*                         ; Set our new error handler
  102.    (setq cht_oe *error* *error* cht_er)
  103.    (setq *error* cht_er)
  104. )
  105. ;; Set undo groups and ends with (eval(read U:G)) or (eval(read U:E))
  106. (setq U:G "(command "undo" "group")"
  107.        U:E "(command "undo" "end")"
  108. )
  109. (setq cht_oc (getvar "cmdecho"))
  110. (setq cht_oh (getvar "highlight"))
  111. (setvar "cmdecho" 0)
  112. (eval(read U:G))
  113. (princ (strcat "\nChange text, Version " pt_ver
  114.                 ", (c) 1990 by Autodesk, Inc. "))
  115. (prompt "\nSelect text to change. ")
  116. (setq sset (ssget))
  117. (if (null sset)
  118.    (progn
  119.      (princ "\nERROR: Nothing selected.")
  120.      (exit)
  121.    )
  122. )
  123. ;; Verify the entity set.
  124. (cht_ve)
  125. ;; This is the main option loop.
  126. (cht_ol)
  127. (if cht_oe (setq *error* cht_oe))   ; Reset old error function if error
  128. (eval(read U:E))
  129. (if cht_ot (setvar "texteval" cht_ot))
  130. (if cht_oh (setvar "highlight" cht_oh))
  131. (if cht_oc (setvar "cmdecho" cht_oc)) ; Reset command echoing
  132. (princ)
  133. )
  134. ;;;
  135. ;;; Verify and sort out non-text entities from the selection set.
  136. ;;;
  137. (defun cht_ve ()
  138. (setq ssl   (sslength sset)
  139.        nsset (ssadd))
  140. (if (> ssl 25)
  141.    (princ "\nVerifying the selected entities -- please wait. ")
  142. )
  143. (while (> ssl 0)
  144.    (setq temp (ssname sset (setq ssl (1- ssl))))
  145.    (if (= (cdr(assoc 0 (entget temp))) "TEXT")
  146.      (ssadd temp nsset)
  147.    )
  148. )
  149. (setq ssl (sslength nsset)
  150.        sset nsset
  151.        unctr 0
  152. )
  153. (print ssl)
  154. (princ "text entities found. ")
  155. )
  156. ;;;
  157. ;;; The option loop.
  158. ;;;
  159. (defun cht_ol ()
  160. (setq opt T)
  161. (while (and opt (> ssl 0))
  162.    (setq unctr (1+ unctr))
  163.    (command "undo" "group")
  164.    (initget "Location Justification Style Height Rotation Width Text Undo")
  165.    (setq opt (getkword
  166.      "\nHeight/Justification/Location/Rotation/Style/Text/Undo/Width: "))
  167.    (if opt
  168.      (cond
  169.        ((= opt "Undo")
  170.          (cht_ue)                    ; Undo the previous command.
  171.        )
  172.        ((= opt "Location")
  173.          (cht_le)                    ; Change the location.
  174.        )
  175.        ((= opt "Justification")
  176.          (cht_je)                    ; Change the justification.
  177.        )
  178.        ((= opt "Style")    (cht_pe "Style"    "style name"      7) )
  179.        ((= opt "Height")   (cht_pe "Height"   "height"         40) )
  180.        ((= opt "Rotation") (cht_pe "Rotation" "rotation angle" 50) )
  181.        ((= opt "Width")    (cht_pe "Width"    "width factor"   41) )
  182.        ((= opt "Text")
  183.          (cht_te)                    ; Change the text.
  184.        )
  185.      )
  186.      (setq opt nil)
  187.    )
  188.    (command "undo" "end")
  189. )
  190. )
  191. ;;;
  192. ;;; Undo an entry.
  193. ;;;
  194. (defun cht_ue ()
  195. (if (> unctr 1)
  196.    (progn
  197.      (command "undo" "end")
  198.      (command "undo" "2")
  199.      (setq unctr (- unctr 2))
  200.    )
  201.    (progn
  202.      (princ "\nNothing to undo. ")
  203.      (setq unctr (- unctr 1))
  204.    )
  205. )
  206. )
  207. ;;;
  208. ;;; Change the location of an entry.
  209. ;;;
  210. (defun cht_le ()
  211. (setq sslen (sslength sset)
  212.        style ""
  213.        hgt   ""
  214.        rot   ""
  215.        txt   ""
  216. )
  217. (command "change" sset "" "")
  218. (while (> sslen 0)
  219.    (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  220.          opt (list (cadr (assoc 11 ent))
  221.                    (caddr (assoc 11 ent))
  222.                    (cadddr (assoc 11 ent)))
  223.    )
  224.    (prompt "\nNew text location: ")
  225.    (command pause)
  226.    (if (null loc)
  227.      (setq loc opt)
  228.    )
  229.    (command style hgt rot txt)
  230. )
  231. (command)
  232. )
  233. ;;;
  234. ;;; Change the justification of an entry.
  235. ;;;
  236. (defun cht_je ()
  237. (if (getvar "DIMCLRD")
  238.    (initget (strcat "TLeft TCenter TRight "
  239.                     "MLeft MCenter Mright "
  240.                     "BLeft BCenter Bright "
  241.                     "Aligned Center Fit Left Middle Right ?"))
  242.    (initget "Aligned Center Fit Left Middle Right ?")
  243. )
  244. (setq sslen (sslength sset))
  245. (setq justp (getkword (strcat "\nJustification point(s) - "
  246.              "Aligned/Center/Fit/Left/Middle/Right/<?>: ")))
  247. (cond
  248.    ((= justp "Left")    (setq justp 0 justq 0) )
  249.    ((= justp "Center")  (setq justp 1 justq 0) )
  250.    ((= justp "Right")   (setq justp 2 justq 0) )
  251.    ((= justp "Aligned") (setq justp 3 justq 0) )
  252.    ((= justp "Fit")     (setq justp 5 justq 0) )
  253.    ((= justp "TLeft")   (setq justp 0 justq 3) )
  254.    ((= justp "TCenter") (setq justp 1 justq 3) )
  255.    ((= justp "TRight")  (setq justp 2 justq 3) )
  256.    ((= justp "MLeft")   (setq justp 0 justq 2) )
  257.    ((= justp "Middle")  (setq justp 1 justq 2) )
  258.    ((= justp "MCenter") (setq justp 1 justq 2) )
  259.    ((= justp "MRight")  (setq justp 2 justq 2) )
  260.    ((= justp "BLeft")   (setq justp 0 justq 1) )
  261.    ((= justp "BCenter") (setq justp 1 justq 1) )
  262.    ((= justp "BRight")  (setq justp 2 justq 1) )
  263.    ((= justp "?")       (setq justp nil)       )
  264.    (T                   (setq justp nil)       )
  265. )   
  266. (if justp
  267.    (justpt) ; Process them...
  268.    (justpn) ; List options...
  269. )
  270. (command)
  271. )
  272. ;;;
  273. ;;; Get alignment points for "aligned" or "fit" text.
  274. ;;;
  275. (defun justpt ()
  276. (while (> sslen 0)
  277.    (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  278.          ent (subst (cons 72 justp) (assoc 72 ent) ent)
  279.          opt (trans (list (cadr (assoc 11 ent))
  280.                           (caddr (assoc 11 ent))
  281.                           (cadddr (assoc 11 ent)))
  282.                     (cdr(assoc -1 ent)) ; from ECS
  283.                     1)               ; to current UCS
  284.    )
  285.    (if (getvar "DIMCLRD")
  286.      (setq ent (subst (cons 73 justq) (assoc 73 ent) ent))
  287.    )
  288.    (cond
  289.      ((or (= justp 3) (= justp 5))
  290.        (prompt "\nNew text alignment points: ")
  291.        (if (= (setq orthom (getvar "orthomode")) 1)
  292.          (setvar "orthomode" 0)
  293.        )
  294.        (redraw (cdr(assoc -1 ent)) 3)
  295.        (initget 1)
  296.        (setq loc (getpoint))
  297.        (initget 1)
  298.        (setq loc1 (getpoint loc))
  299.        (redraw (cdr(assoc -1 ent)) 1)
  300.        (setvar "orthomode" orthom)
  301.        (setq ent (subst (cons 10 loc) (assoc 10 ent) ent))
  302.        (setq ent (subst (cons 11 loc1) (assoc 11 ent) ent))
  303.      )
  304.      ((/= justp 0)
  305.        (redraw (cdr(assoc -1 ent)) 3)
  306.        (prompt "\nNew text location: ")
  307.        (if (= (setq orthom (getvar "orthomode")) 1)
  308.          (setvar "orthomode" 0)
  309.        )
  310.        (setq loc (getpoint opt))
  311.        (setvar "orthomode" orthom)
  312.        (redraw (cdr(assoc -1 ent)) 1)
  313.        (if (null loc)
  314.          (setq loc opt)
  315.          (setq loc (trans loc 1 (cdr(assoc -1 ent))))
  316.        )
  317.        (setq ent (subst (cons 11 loc) (assoc 11 ent) ent))
  318.      )
  319.    )
  320.    (entmod ent)
  321. )
  322. )
  323. ;;;
  324. ;;; List the options.
  325. ;;;
  326. (defun justpn ()
  327. (if (getvar "DIMCLRD") (textpage))
  328. (princ "\nAlignment options: ")
  329. (princ "\n\t TLeft   TCenter   TRight ")
  330. (princ "\n\t MLeft   MCenter   MRight ")
  331. (princ "\n\t BLeft   BCenter   BRight ")
  332. (princ "\n\t  Left    Center    Right")
  333. (princ "\n\tAligned   Middle    Fit")
  334. (if (not (getvar "DIMCLRD")) (textscr))
  335. (princ "\n\nPress any key to return to your drawing. ")
  336. (grread)
  337. (princ "\r                                           ")
  338. (graphscr)
  339. )
  340. ;;;
  341. ;;; Change the text of an entity.
  342. ;;;
  343. (defun cht_te ()
  344. (setq sslen (sslength sset))
  345. (initget "Globally Individually Retype")
  346. (setq ans (getkword
  347.    "\nSearch and replace text.  Individually/Retype/<Globally>:"))
  348. (setq cht_ot (getvar "texteval"))
  349. (setvar "texteval" 1)
  350. (cond
  351.    ((= ans "Individually")
  352.      (if (= (getvar "popups") 1)
  353.        (progn
  354.          (initget "Yes No")
  355.          (setq ans (getkword "\nEdit text in dialogue? <Yes>:"))
  356.        )
  357.        (setq ans "No")
  358.      )
  359.      (while (> sslen 0)
  360.        (redraw (setq sn (ssname sset (setq sslen (1- sslen)))) 3)
  361.        (setq ss (ssadd))
  362.        (ssadd (ssname sset sslen) ss)
  363.        (if (= ans "No")
  364.          (chgtext ss)
  365.          (command "ddedit" sn "")
  366.        )
  367.        (redraw sn 1)
  368.      )
  369.    )
  370.    ((= ans "Retype")
  371.      (while (> sslen 0)
  372.        (setq ent (entget(ssname sset (setq sslen (1- sslen)))))
  373.        (redraw (cdr(assoc -1 ent)) 3)
  374.        (prompt (strcat "\nOld text: " (cdr(assoc 1 ent))))
  375.        (setq nt (getstring  T "\nNew text: "))
  376.        (redraw (cdr(assoc -1 ent)) 1)
  377.        (if (> (strlen nt) 0)
  378.          (entmod (subst (cons 1 nt) (assoc 1 ent) ent))
  379.        )
  380.      )
  381.    )
  382.    (T
  383.      (chgtext sset)                  ; Change 'em all
  384.    )
  385. )
  386. (setvar "texteval" cht_ot)
  387. )
  388. ;;;
  389. ;;; The old CHGTEXT command - rudimentary text editor
  390. ;;;
  391. ;;;
  392. (defun C:CHGTEXT () (chgtext nil))
  393. (defun chgtext (objs / last_o tot_o ent o_str n_str st s_temp
  394.                       n_slen o_slen si chf chm cont ans)
  395. (if (null objs)
  396.    (setq objs (ssget))               ; Select objects if running standalone
  397. )
  398. (setq chm 0)
  399. (if objs
  400.    (progn                   ; If any objects selected
  401.      (if (= (type objs) 'ENAME)
  402.        (progn
  403.          (setq ent (entget objs))
  404.          (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  405.        )
  406.        (if (= (sslength objs) 1)
  407.          (progn
  408.            (setq ent (entget (ssname objs 0)))
  409.            (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  410.          )
  411.        )
  412.      )
  413.      (setq o_str (getstring "\nMatch string   : " t))
  414.      (setq o_slen (strlen o_str))
  415.      (if (/= o_slen 0)
  416.        (progn
  417.          (setq n_str (getstring "\nNew string     : " t))
  418.          (setq n_slen (strlen n_str))
  419.          (setq last_o 0
  420.                tot_o  (if (= (type objs) 'ENAME)
  421.                         1
  422.                         (sslength objs)
  423.                       )
  424.          )
  425.          (while (< last_o tot_o)     ; For each selected object...
  426.            (if (= "TEXT"             ; Look for TEXT entity type (group 0)
  427.                   (cdr (assoc 0 (setq ent (entget (ssname objs last_o))))))
  428.              (progn
  429.                (setq chf nil si 1)
  430.                (setq s_temp (cdr (assoc 1 ent)))
  431.                (while (= o_slen (strlen (setq st (substr s_temp si o_slen))))
  432.                  (if (= st o_str)
  433.                    (progn
  434.                      (setq s_temp (strcat
  435.                                     (if (> si 1)
  436.                                       (substr s_temp 1 (1- si))
  437.                                       ""
  438.                                     )
  439.                                     n_str
  440.                                     (substr s_temp (+ si o_slen))
  441.                                   )
  442.                      )
  443.                      (setq chf t)    ; Found old string
  444.                      (setq si (+ si n_slen))
  445.                    )
  446.                    (setq si (1+ si))
  447.                  )
  448.                )
  449.                (if chf
  450.                  (progn              ; Substitute new string for old
  451.                    ; Modify the TEXT entity
  452.                    (entmod (subst (cons 1 s_temp) (assoc 1 ent) ent))
  453.                    (setq chm (1+ chm))
  454.                  )
  455.                )
  456.              )
  457.            )
  458.            (setq last_o (1+ last_o))
  459.          )
  460.        )
  461.        ;; else go on to the next line...
  462.      )
  463.    )
  464. )
  465. (if (/= (type objs) 'ENAME)
  466.    (if (/= (sslength objs) 1)        ; Print total lines changed
  467.      (princ (strcat "Changed "
  468.                     (rtos chm 2 0)
  469.                     " text lines."
  470.             )
  471.      )
  472.    )
  473. )
  474. (terpri)
  475. )
  476. ;;;
  477. ;;; Main procedure for manipulating text entities
  478. ;;; ARGUMENTS:
  479. ;;;   typ   -- Type of operation to perform
  480. ;;;   prmpt -- Partial prompt string to insert in standard prompt line
  481. ;;;   fld   -- Assoc field to be changed
  482. ;;; GLOBALS:
  483. ;;;   sset  -- The selection set of text entities
  484. ;;;
  485. (defun cht_pe (typ prmpt fld / temp ow nw ent tw sty w hw lw
  486.                              sslen n sn ssl)
  487. (if (= (sslength sset) 1)           ; Special case if there is only
  488.                                      ; one entity selected
  489.    ;; Process one entity.
  490.    (cht_p1)
  491.    ;; Else
  492.    (progn
  493.      ;; Set prompt string.
  494.      (cht_sp)
  495.      (if (= nw "List")
  496.        ;; Process List request.
  497.        (cht_pl)
  498.        (if (= nw "Individual")
  499.          ;; Process Individual request.
  500.          (cht_pi)
  501.          (if (= nw "Select")
  502.            ;; Process Select request.
  503.            (cht_ps)
  504.            ;; Else
  505.            (progn
  506.              (if (= typ "Rotation")
  507.                (setq nw (* (/ nw 180.0) pi))
  508.              )
  509.              (if (= (type nw) 'STR)
  510.                (if (not (tblsearch "style" nw))
  511.                  (progn
  512.                    (princ (strcat "\nStyle " nw " not found. "))
  513.                  )
  514.                  (cht_pa)
  515.                )
  516.                (cht_pa)
  517.              )
  518.            )
  519.          )
  520.        )
  521.      )
  522.    )
  523. )
  524. )
  525. ;;;
  526. ;;; Change all of the entities in the selection set.
  527. ;;;
  528. (defun cht_pa ()
  529. (setq sslen (sslength sset))
  530. (setq cht_oh (getvar "texteval"))
  531. (setvar "highlight" 0)
  532. (while (> sslen 0)
  533.    (setq temp (ssname sset (setq sslen (1- sslen))))
  534.    (entmod (subst (cons fld nw)
  535.                   (assoc fld (setq ent (entget temp)))
  536.                   ent
  537.            )
  538.    )
  539.    
  540. )
  541. (setvar "highlight" cht_oh)
  542. )
  543. ;;;
  544. ;;; Change one text entity.
  545. ;;;
  546. (defun cht_p1 ()
  547. (setq temp (ssname sset 0))
  548. (setq ow (cdr(assoc fld (entget temp))))
  549. (if (= opt "Rotation")
  550.    (setq ow (/ (* ow 180.0) pi))
  551. )
  552. (redraw (cdr(assoc -1 (entget temp))) 3)
  553. (initget 0)
  554. (if (= opt "Style")
  555.    (setq nw (getstring (strcat "\nNew " prmpt ". <"
  556.                              ow ">: ")))
  557.    (setq nw (getreal (strcat "\nNew " prmpt ". <"
  558.                              (rtos ow 2) ">: ")))
  559. )
  560. (if (or (= nw "") (= nw nil))
  561.    (setq nw ow)
  562. )
  563. (redraw (cdr(assoc -1 (entget temp))) 1)
  564. (if (= opt "Rotation")
  565.    (setq nw (* (/ nw 180.0) pi))
  566. )
  567. (if (= opt "Style")
  568.    (if (null (tblsearch "style" nw))
  569.      (princ (strcat "\nStyle " nw " not found. "))
  570.      
  571.      (entmod (subst (cons fld nw)
  572.                     (assoc fld (setq ent (entget temp)))
  573.                     ent
  574.              )
  575.      )
  576.    )
  577.    (entmod (subst (cons fld nw)
  578.                   (assoc fld (setq ent (entget temp)))
  579.                   ent
  580.            )
  581.    )
  582. )
  583. )
  584. ;;;
  585. ;;; Set the prompt string.
  586. ;;;
  587. (defun cht_sp ()
  588. (if (= typ "Style")
  589.    (progn
  590.      (initget "Individual List New Select ")
  591.      (setq nw (getkword (strcat "\nIndividual/List/Select style/<New "
  592.                                 prmpt
  593.                                 " for all text entities>: ")))
  594.      (if (or (= nw "") (= nw nil) (= nw "Enter"))
  595.        (setq nw (getstring (strcat "\nNew "
  596.                                    prmpt
  597.                                    " for all text entities: ")))
  598.      )
  599.    )
  600.    (progn
  601.      (initget "List Individual" 1)
  602.      (setq nw (getreal (strcat "\nIndividual/List/<New "
  603.                                 prmpt
  604.                                 " for all text entities>: ")))
  605.    )
  606. )
  607. )
  608. ;;;
  609. ;;; Process List request.
  610. ;;;
  611. (defun cht_pl ()
  612. (setq unctr (1- unctr))
  613. (setq sslen (sslength sset))
  614. (setq tw 0)
  615. (while (> sslen 0)
  616.    (setq temp (ssname sset (setq sslen (1- sslen))))
  617.    (if (= typ "Style")
  618.      (progn
  619.        (if (= tw 0)
  620.          (setq tw (list (cdr(assoc fld (entget temp)))))
  621.          (progn
  622.            (setq sty (cdr(assoc fld (entget temp))))
  623.            (if (not (member sty tw))
  624.              (setq tw (append tw (list sty)))
  625.            )
  626.          )
  627.        )
  628.      )
  629.      (progn
  630.        (setq tw (+ tw (setq w (cdr(assoc fld (entget temp))))))
  631.        (if (= (sslength sset) (1+ sslen)) (setq lw w hw w))
  632.        (if (< hw w) (setq hw w))
  633.        (if (> lw w) (setq lw w))
  634.      )
  635.    )
  636. )
  637. (if (= typ "Rotation")
  638.    (setq tw (* (/ tw pi) 180.0)
  639.          lw (* (/ lw pi) 180.0)
  640.          hw (* (/ hw pi) 180.0))
  641. )
  642. (if (= typ "Style")
  643.    (progn
  644.      (princ (strcat "\n"
  645.                     typ
  646.                     "(s) -- "))
  647.      (princ tw)
  648.    )
  649.    (princ (strcat "\n"
  650.                     typ
  651.                     " -- Min: "
  652.                     (rtos lw 2)
  653.                     "\t Max: "
  654.                     (rtos hw 2)
  655.                     "\t Avg: "
  656.                     (rtos (/ tw (sslength sset)) 2) ))
  657. )
  658. )
  659. ;;;
  660. ;;; Process Individual request.
  661. ;;;
  662. (defun cht_pi ()
  663. (setq sslen (sslength sset))
  664. (while (> sslen 0)
  665.    (setq temp (ssname sset (setq sslen (1- sslen))))
  666.    (setq ow (cdr(assoc fld (entget temp))))
  667.    (if (= typ "Rotation")
  668.      (setq ow (/ (* ow 180.0) pi))
  669.    )
  670.    (initget 0)
  671.    (redraw (cdr(assoc -1 (entget temp))) 3)
  672.    (if (= typ "Style")
  673.      (progn
  674.        (setq nw (getstring (strcat "\nNew "
  675.                                   prmpt
  676.                                   ". <"
  677.                                   ow ">: ")))
  678.      )
  679.      (progn
  680.        (setq nw (getreal (strcat "\nNew "
  681.                                   prmpt
  682.                                   ". <"
  683.                                (rtos ow 2) ">: ")))
  684.      )
  685.    )
  686.    (if (or (= nw "") (= nw nil))
  687.      (setq nw ow)
  688.    )
  689.    (if (= typ "Rotation")
  690.      (setq nw (* (/ nw 180.0) pi))
  691.    )
  692.    (entmod (subst (cons fld nw)
  693.                   (assoc fld (setq ent (entget temp)))
  694.                   ent
  695.            )
  696.    )
  697.    (redraw (cdr(assoc -1 (entget temp))) 1)
  698. )
  699. )
  700. ;;;
  701. ;;; Process the Select option.
  702. ;;;
  703. (defun cht_ps ()
  704. (princ "\nSearch for which Style name?  <*>: ")
  705. (setq sn  (strcase (getstring))
  706.        n   -1
  707.        sset nsset
  708.        nsset (ssadd)
  709.        ssl (1- (sslength sset))
  710.        )
  711. (if (or (= sn "*") (null sn) (= sn ""))
  712.    (setq nsset sset sn "*")
  713.    (while (and sn (< n ssl))
  714.      (setq temp (ssname sset (setq n (1+ n))))
  715.      (if (= (cdr(assoc 7 (entget temp))) sn)
  716.        (ssadd temp nsset)
  717.      )
  718.    )
  719. )
  720. (setq ssl (sslength nsset))  
  721. (princ "\nFound ")
  722. (princ ssl)
  723. (princ " text entities with STYLE of ")
  724. (princ sn)
  725. (princ ". ")
  726. (setq sset nsset)
  727. )
  728. ;;;
  729. ;;; The C: function definition.
  730. ;;;
  731. (defun c:cht    () (chtxt))
  732. (princ "\n\tc:CHText loaded.  Start command with CHT.")
  733. (princ)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 23:15:59 | 显示全部楼层
即使是1.4版的大多数Lisp程序都会在34年前运行。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-11 06:14 , Processed in 0.743548 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表