乐筑天下

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

[编程交流] 如何让autocad加载l

[复制链接]

6

主题

15

帖子

9

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 15:41:19 | 显示全部楼层 |阅读模式
这可能是一个很容易回答的问题。我最近从AutoCAD 2006迁移到AutoCAD 2018,正在学习所有更改。一件不起作用的事情是我有一个按钮,用于更改一些文本,当它试图加载lisp文件时,它会掉下来。我已将lisp文件保存在支持文件夹中,并确保位置显示在支持文件搜索路径中,但当它尝试按钮内的脚本时,返回错误消息:
 
命令:(加载“chtext”)
; 错误:错误的参数类型:stringp nil
 
有什么想法吗?
提前感谢
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 15:53:14 | 显示全部楼层
这是版本的飞跃!如果您发布代码,那么调试将最容易。
回复

使用道具 举报

6

主题

15

帖子

9

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 16:00:38 | 显示全部楼层
  1. ;;;    CHTEXT.lsp - change text
  2. ;;;
  3. ;;;    Copyright 1997 by Autodesk, Inc.
  4. ;;;
  5. ;;;    Permission to use, copy, modify, and distribute this software
  6. ;;;    for any purpose and without fee is hereby granted, provided
  7. ;;;    that the above copyright notice appears in all copies and
  8. ;;;    that both that copyright notice and the limited warranty and
  9. ;;;    restricted rights notice below appear in all supporting
  10. ;;;    documentation.
  11. ;;;
  12. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  13. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  14. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  15. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  16. ;;;    UNINTERRUPTED OR ERROR FREE.
  17. ;;;
  18. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  19. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  20. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  21. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  22. ;;;  
  23. ;;;--------------------------------------------------------------------------;
  24. ;;; DESCRIPTION
  25. ;;;   This is a "text processor" which operates in a global manner
  26. ;;;   on all of the text entities that the user selects; i.e., the
  27. ;;;   Height, Justification, Location, Rotation, Style, Text, and
  28. ;;;   Width can all be changed globally or individually, and the
  29. ;;;   range of values for a given parameter can be listed.
  30. ;;;   
  31. ;;;   The command is called with CHT from the command line at which
  32. ;;;   time the user is asked to select the objects to change.
  33. ;;;   
  34. ;;;     Select text to change.
  35. ;;;     Select objects:
  36. ;;;  
  37. ;;;   If nothing is selected the message "ERROR: Nothing selected."
  38. ;;;   is displayed and the command is terminated.  If more than 25
  39. ;;;   entities are selected the following message is displayed while
  40. ;;;   the text entities are sorted out from the non-text entities.
  41. ;;;   A count of the text entities found is then displayed.
  42. ;;;   
  43. ;;;     Verifying the selected entities...
  44. ;;;     nnn  text entities found.
  45. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  46. ;;;   
  47. ;;;   A typical example of the prompts you may encounter follows:
  48. ;;;   
  49. ;;;   If you select a single text entity to change and ask to change
  50. ;;;   the height, the prompt looks like this:
  51. ;;;   
  52. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  53. ;;;     New text height for text entity. <0.08750000>:
  54. ;;;   
  55. ;;;   If you select more than one text entity to change and ask to change
  56. ;;;   the height, the prompt looks like this:
  57. ;;;   
  58. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  59. ;;;     Individual/List/<New height for all entities>:
  60. ;;;   
  61. ;;;   Typing "L" at this prompt returns a prompt showing you the range of
  62. ;;;   values that you are using for your text.
  63. ;;;   
  64. ;;;     Height -- Min: 0.05000000  Max: 0.10000000  Ave: 0.08392857
  65. ;;;   
  66. ;;;   Typing "I" at this prompt puts you in a loop, processing the text
  67. ;;;   entities you have selected one at a time, and giving the same prompt
  68. ;;;   you get for a single text entity shown above.
  69. ;;;   
  70. ;;;   Pressing ENTER at this point puts you back at the Command: prompt.
  71. ;;;   Selecting any of the other options allows you to change the text
  72. ;;;   entities selected.
  73. ;;;   
  74. ;;;---------------------------------------------------------------------------;
  75. (defun cht_Main ( / sset opt ssl nsset temp unctr ct_ver sslen style hgt rot
  76.                    txt ent loc loc1 just-idx justp justq orthom
  77.                    cht_ErrorHandler cht_OrgError cht_OrgCmdecho
  78.                    cht_OrgTexteval cht_OrgHighlight)
  79. ;; Reset if changed
  80. (setq ct_ver "2.00")
  81. ;; Internal error handler defined locally
  82. (defun cht_ErrorHandler (s)
  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.    ;;  Reset original error handler if there
  91.    (if cht_OrgError (setq *error* cht_OrgError))
  92.    (if temp (redraw temp 1))
  93.    (ai_undo_off) ;; restore undo state
  94.    (if cht_OrgCmdecho (setvar "cmdecho" cht_OrgCmdecho))
  95.    (if cht_OrgTexteval (setvar "texteval" cht_OrgTexteval))
  96.    (if cht_OrgHighlight (setvar "highlight" cht_OrgHighlight))
  97.    (princ)
  98. )
  99. ;; Set error handler
  100. (if *error*
  101.    (setq cht_OrgError *error*
  102.          *error* cht_ErrorHandler)
  103.    (setq *error* cht_ErrorHandler)
  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" "_en")"
  108. )
  109. (ai_undo_on)       ;; enable undo
  110. (setq cht_OrgCmdecho (getvar "cmdecho"))
  111. (setq cht_OrgHighlight (getvar "highlight"))
  112. (setvar "cmdecho" 0)
  113. (princ (strcat "\nChange text, Version "
  114.                 ct_ver
  115.                 ", Copyright © 1997 by Autodesk, Inc."))
  116. (prompt "\nSelect annotation objects to change.")
  117. (setq sset (ai_aselect))
  118. (if (null sset)
  119.    (progn
  120.      (princ "\nNo objects selected.")
  121.      (exit)
  122.    )
  123. )
  124. ;; Validate selection set
  125. (setq ssl   (sslength sset)
  126.        nsset (ssadd))
  127. (if (> ssl 25)
  128.    (princ "\nVerifying selected objects...")
  129. )
  130. (while (> ssl 0)
  131.    (setq temp (ssname sset (setq ssl (1- ssl))))
  132.    (if (or
  133.          (= (cdr (assoc 0 (entget temp))) "TEXT")
  134.          (= (cdr (assoc 0 (entget temp))) "ATTDEF")
  135.          (= (cdr (assoc 0 (entget temp))) "MTEXT")
  136.        )
  137.      (ssadd temp nsset)
  138.    )
  139. )
  140. (setq ssl (sslength nsset)
  141.        sset nsset
  142.        unctr 0
  143. )
  144. (print ssl)
  145. (princ "annotation objects found.")
  146. ;; Main loop
  147. (setq opt T)
  148. (while (and opt (> ssl 0))
  149.    (setq unctr (1+ unctr))
  150.    (command "_.UNDO" "_GROUP")
  151.    (initget "Location Justification Style Height Rotation Width Text Undo")
  152.    (setq opt (getkword
  153.      "\nHeight/Justification/Location/Rotation/Style/Text/Undo/Width: "))
  154.    (if opt
  155.      (cond
  156.        ((= opt "Undo")
  157.          (cht_Undo)
  158.        )
  159.        ((= opt "Location")
  160.          (cht_Location)
  161.        )
  162.        ((= opt "Justification")
  163.          (cht_Justification)
  164.        )
  165.        ((= opt "Style")
  166.          (cht_Property "Style"    "New style name"      7) )
  167.        ((= opt "Height")
  168.          (cht_Property "Height"   "New height"         40) )
  169.        ((= opt "Rotation")
  170.          (cht_Property "Rotation" "New rotation angle" 50) )
  171.        ((= opt "Width")
  172.          (cht_Property "Width"    "New width factor"   41) )
  173.        ((= opt "Text")
  174.          (cht_Text)
  175.        )
  176.      )
  177.      (setq opt nil)
  178.    )
  179.    (command "_.UNDO" "_END")
  180. )
  181. ;; Restore
  182. (if cht_OrgError (setq *error* cht_OrgError))
  183. (eval (read U:E))
  184. (ai_undo_off) ;; restore undo state
  185. (if cht_OrgTexteval (setvar "texteval" cht_OrgTexteval))
  186. (if cht_OrgHighlight (setvar "highlight" cht_OrgHighlight))
  187. (if cht_OrgCmdecho (setvar "cmdecho" cht_OrgCmdecho))
  188. (princ)
  189. )
  190. ;;; Undo an entry
  191. (defun cht_Undo ()
  192. (if (> unctr 1)
  193.    (progn
  194.      (command "_.UNDO" "_END")
  195.      (command "_.UNDO" "2")
  196.      (setq unctr (- unctr 2))
  197.    )
  198.    (progn
  199.      (princ "\nNothing to undo. ")
  200.      (setq unctr (- unctr 1))
  201.    )
  202. )
  203. )
  204. ;;; Change the location of an entry
  205. (defun cht_Location ()
  206. (setq sslen (sslength sset)
  207.        style ""
  208.        hgt   ""
  209.        rot   ""
  210.        txt   ""
  211. )
  212. ;;LCA - COMMENT: The CHANGE command has new options.
  213. (command "_.CHANGE" sset "" "")
  214. (while (> sslen 0)
  215.    (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  216.          opt (list (cadr (assoc 11 ent))
  217.                    (caddr (assoc 11 ent))
  218.                    (cadddr (assoc 11 ent)))
  219.    )
  220.    (prompt "\nNew text location: ")
  221.    (command pause)
  222.    (if (null loc)
  223.      (setq loc opt)
  224.    )
  225.    (command style hgt rot txt)
  226. )
  227. (command)
  228. )
  229. ;;; Change the justification of an entry
  230. (defun cht_Justification ()
  231. (initget "TL TC TR ML MC MR BL BC BR Align Center Fit Left Middle Right ?")
  232. (setq sslen (sslength sset))
  233. (setq justp (getkword "\nAlign/Fit/Center/Left/Middle/Right/TL/TC/TR/ML/MC/MR/BL/BC/BR/<?>: "))
  234. (cond
  235.    ((= justp "Left")    (setq justp 0 justq 0 just-idx 4) )
  236.    ((= justp "Center")  (setq justp 1 justq 0 just-idx 5) )
  237.    ((= justp "Right")   (setq justp 2 justq 0 just-idx 6) )
  238.    ((= justp "Align")   (setq justp 3 justq 0 just-idx 1) )
  239.    ((= justp "Fit")     (setq justp 5 justq 0 just-idx 1) )
  240.    ((= justp "TL")      (setq justp 0 justq 3 just-idx 1) )
  241.    ((= justp "TC")      (setq justp 1 justq 3 just-idx 2) )
  242.    ((= justp "TR")      (setq justp 2 justq 3 just-idx 3) )
  243.    ((= justp "ML")      (setq justp 0 justq 2 just-idx 4) )
  244.    ((= justp "Middle")  (setq justp 4 justq 0 just-idx 5) )
  245.    ((= justp "MC")      (setq justp 1 justq 2 just-idx 5) )
  246.    ((= justp "MR")      (setq justp 2 justq 2 just-idx 6) )
  247.    ((= justp "BL")      (setq justp 0 justq 1 just-idx 7) )
  248.    ((= justp "BC")      (setq justp 1 justq 1 just-idx  )
  249.    ((= justp "BR")      (setq justp 2 justq 1 just-idx 9) )
  250.    ((= justp "?")       (setq justp nil)       )
  251.    (T                   (setq justp nil)       )
  252. )   
  253. (if justp
  254.    (progn ;; Process them...
  255.      (while (> sslen 0)
  256.        (setq ent (entget (ssname sset (setq sslen (1- sslen)))))
  257.        (cond
  258.          ((= (cdr (assoc 0 ent)) "MTEXT")
  259.            (setq ent (subst (cons 71 just-idx) (assoc 71 ent) ent))
  260.          )
  261.          ((= (cdr (assoc 0 ent)) "TEXT")
  262.            (setq ent (subst (cons 72 justp) (assoc 72 ent) ent)
  263.                  opt (trans (list (cadr (assoc 11 ent))
  264.                                   (caddr (assoc 11 ent))
  265.                                   (cadddr (assoc 11 ent)))
  266.                             (cdr (assoc -1 ent)) ;; from ECS
  267.                             1)               ;; to current UCS
  268.            )
  269.            (setq ent (subst (cons 73 justq) (assoc 73 ent) ent))
  270.            (cond
  271.              ((or (= justp 3) (= justp 5))
  272.                (prompt "\nNew text alignment points: ")
  273.                (if (= (setq orthom (getvar "orthomode")) 1)
  274.                  (setvar "orthomode" 0)
  275.                )
  276.                (redraw (cdr (assoc -1 ent)) 3)
  277.                (initget 1)
  278.                (setq loc (getpoint))
  279.                (initget 1)
  280.                (setq loc1 (getpoint loc))
  281.                (redraw (cdr (assoc -1 ent)) 1)
  282.                (setvar "orthomode" orthom)
  283.                (setq ent (subst (cons 10 loc) (assoc 10 ent) ent))
  284.                (setq ent (subst (cons 11 loc1) (assoc 11 ent) ent))
  285.              )
  286.              ((or (/= justp 0) (/= justq 0))
  287.                (redraw (cdr (assoc -1 ent)) 3)
  288.                (prompt "\nNew text location: ")
  289.                (if (= (setq orthom (getvar "orthomode")) 1)
  290.                  (setvar "orthomode" 0)
  291.                )
  292.                (setq loc (getpoint opt))
  293.                (setvar "orthomode" orthom)
  294.                (redraw (cdr (assoc -1 ent)) 1)
  295.                (if (null loc)
  296.                  (setq loc opt)
  297.                  (setq loc (trans loc 1 (cdr (assoc -1 ent))))
  298.                )
  299.                (setq ent (subst (cons 11 loc) (assoc 11 ent) ent))
  300.              )
  301.            )
  302.          )
  303.        )
  304.        (entmod ent)
  305.      )
  306.    )
  307.    (progn        ;; otherwise list options
  308.      (textpage)
  309.      (princ "\nAlignment options:\n")
  310.      (princ "\t  TL     TC      TR\n")
  311.      (princ "\t  ML     MC      MR\n")
  312.      (princ "\t  BL     BC      BR\n")
  313.      (princ "\t Left   Center  Right\n")
  314.      (princ "\tAlign   Middle  Fit\n")
  315.      (princ "\nPress ENTER to continue: ")
  316.      (grread)
  317.      (princ "\r                                                            ")
  318.      (graphscr)
  319.    )
  320. )
  321. (command)
  322. )
  323. ;;; Change the text of an object
  324. (defun cht_Text ( / ans)
  325. (setq sslen (sslength sset))
  326. (initget "Globally Individually Retype")
  327. (setq ans (getkword
  328.    "\nFind and replace text.  Individually/Retype/<Globally>:"))
  329. (setq cht_OrgTexteval (getvar "texteval"))
  330. (setvar "texteval" 1)
  331. (cond
  332.    ((= ans "Individually")
  333.      (progn
  334.        (initget "Yes No")
  335.        (setq ans (getkword "\nEdit text in dialog? <Yes>:"))
  336.      )
  337.      (while (> sslen 0)
  338.        (redraw (setq sn (ssname sset (setq sslen (1- sslen)))) 3)
  339.        (setq ss (ssadd))
  340.        (ssadd (ssname sset sslen) ss)
  341.        (if (= ans "No")
  342.          (cht_Edit ss)
  343.          (command "_.DDEDIT" sn "")
  344.        )
  345.        (redraw sn 1)
  346.      )
  347.    )
  348.    ((= ans "Retype")
  349.      (while (> sslen 0)
  350.        (setq ent (entget (ssname sset (setq sslen (1- sslen)))))
  351.        (redraw (cdr (assoc -1 ent)) 3)
  352.        (prompt (strcat "\nOld text: " (cdr (assoc 1 ent))))
  353.        (setq nt (getstring  T "\nNew text: "))
  354.        (redraw (cdr (assoc -1 ent)) 1)
  355.        (if (> (strlen nt) 0)
  356.          (entmod (subst (cons 1 nt) (assoc 1 ent) ent))
  357.        )
  358.      )
  359.    )
  360.    (T
  361.      (cht_Edit sset)   ;; Change all
  362.    )
  363. )
  364. (setvar "texteval" cht_OrgTexteval)
  365. )
  366. ;;; The old CHGTEXT command - rudimentary text editor
  367. (defun C:CHGTEXT () (cht_Edit nil))
  368. (defun cht_Edit (objs / last_o tot_o ent o_str n_str st s_temp
  369.                       n_slen o_slen si chf chm cont ans class)
  370. ;; Select objects if running standalone
  371. (if (null objs)
  372.    (setq objs (ssget))
  373. )
  374. (setq chm 0)
  375. (if objs
  376.    (progn                   ;; If any objects selected
  377.      (if (= (type objs) 'ENAME)
  378.        (progn
  379.          (setq ent (entget objs))
  380.          (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  381.        )
  382.        (if (= (sslength objs) 1)
  383.          (progn
  384.            (setq ent (entget (ssname objs 0)))
  385.            (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  386.          )
  387.        )
  388.      )
  389.      (setq o_str (getstring "\nMatch string   : " t))
  390.      (setq o_slen (strlen o_str))
  391.      (if (/= o_slen 0)
  392.        (progn
  393.          (setq n_str (getstring "\nNew string     : " t))
  394.          (setq n_slen (strlen n_str))
  395.          (setq last_o 0
  396.                tot_o  (if (= (type objs) 'ENAME)
  397.                         1
  398.                         (sslength objs)
  399.                       )
  400.          )
  401.          ;; For each selected object...
  402.          (while (< last_o tot_o)
  403.            (setq class (cdr (assoc 0 (setq ent (entget (ssname objs last_o))))))
  404.            (if (or (= "TEXT" class)
  405.                    (= "MTEXT" class) )
  406.              (progn
  407.                (setq chf nil si 1)
  408.                (setq s_temp (cdr (assoc 1 ent)))
  409.                (while (= o_slen (strlen (setq st (substr s_temp si o_slen))))
  410.                  (if (= st o_str)
  411.                    (progn
  412.                      (setq s_temp (strcat
  413.                                     (if (> si 1)
  414.                                       (substr s_temp 1 (1- si))
  415.                                       ""
  416.                                     )
  417.                                     n_str
  418.                                     (substr s_temp (+ si o_slen))
  419.                                   )
  420.                      )
  421.                      (setq chf t)    ;; Found old string
  422.                      (setq si (+ si n_slen))
  423.                    )
  424.                    (setq si (1+ si))
  425.                  )
  426.                )
  427.                (if chf
  428.                  (progn              ;; Substitute new string for old
  429.                    ;; Modify the TEXT entity
  430.                    (entmod (subst (cons 1 s_temp) (assoc 1 ent) ent))
  431.                    (setq chm (1+ chm))
  432.                  )
  433.                )
  434.              )
  435.            )
  436.            (setq last_o (1+ last_o))
  437.          )
  438.        )
  439.        ;; else go on to the next line...
  440.      )
  441.    )
  442. )
  443. (if (/= (type objs) 'ENAME)
  444.    ;; Print total lines changed
  445.    (if (/= (sslength objs) 1)
  446.      (princ (strcat (rtos chm 2 0) " text lines changed."))
  447.    )
  448. )
  449. (terpri)
  450. )
  451. ;;; Main procedure for manipulating text entities
  452. (defun cht_Property (typ prmpt fld / temp ow nw ent tw sty w hw lw
  453.                              sslen n sn ssl)
  454. (if (= (sslength sset) 1)           ;; Special case if there is only
  455.                                      ;; one entity selected
  456.    ;; Process one entity.
  457.    (cht_ProcessOne)
  458.    ;; Else
  459.    (progn
  460.      ;; Set prompt string.
  461.      (cht_SetPrompt)
  462.      (if (= nw "List")
  463.        ;; Process List request.
  464.        (cht_ProcessList)
  465.        (if (= nw "Individual")
  466.          ;; Process Individual request.
  467.          (cht_ProcessIndividual)
  468.          (if (= nw "Select")
  469.            ;; Process Select request.
  470.            (cht_ProcessSelect)
  471.            ;; Else
  472.            (progn
  473.              (if (= typ "Rotation")
  474.                (setq nw (* (/ nw 180.0) pi))
  475.              )
  476.              (if (= (type nw) 'STR)
  477.                (if (not (tblsearch "style" nw))
  478.                  (progn
  479.                    (princ (strcat nw ": Style not found. "))
  480.                  )
  481.                  (cht_ProcessAll)
  482.                )
  483.                (cht_ProcessAll)
  484.              )
  485.            )
  486.          )
  487.        )
  488.      )
  489.    )
  490. )
  491. )
  492. ;;; Change all of the entities in the selection set
  493. (defun cht_ProcessAll (/ hl temp)
  494. (setq sslen (sslength sset))
  495. (setq hl (getvar "highlight"))
  496. (setvar "highlight" 0)
  497. (while (> sslen 0)
  498.    (setq temp (ssname sset (setq sslen (1- sslen))))
  499.    (entmod (subst (cons fld nw)
  500.                   (assoc fld (setq ent (entget temp)))
  501.                   ent ) )
  502. )
  503. (setvar "highlight" hl)
  504. )
  505. ;;; Change one text entity
  506. (defun cht_ProcessOne ()
  507. (setq temp (ssname sset 0))
  508. (setq ow (cdr (assoc fld (entget temp))))
  509. (if (= opt "Rotation")
  510.    (setq ow (/ (* ow 180.0) pi))
  511. )
  512. (redraw (cdr (assoc -1 (entget temp))) 3)
  513. (initget 0)
  514. (if (= opt "Style")
  515.    (setq nw (getstring (strcat prmpt " <" ow ">: ")))
  516.    (setq nw (getreal (strcat prmpt " <" (rtos ow 2) ">: ")))
  517. )
  518. (if (or (= nw "") (= nw nil))
  519.    (setq nw ow)
  520. )
  521. (redraw (cdr (assoc -1 (entget temp))) 1)
  522. (if (= opt "Rotation")
  523.    (setq nw (* (/ nw 180.0) pi))
  524. )
  525. (if (= opt "Style")
  526.    (if (null (tblsearch "style" nw))
  527.      (princ (strcat nw ": Style not found. "))
  528.      (entmod (subst (cons fld nw)
  529.                     (assoc fld (setq ent (entget temp)))
  530.                     ent
  531.              )
  532.      )
  533.    )
  534.    (entmod (subst (cons fld nw)
  535.                   (assoc fld (setq ent (entget temp)))
  536.                   ent
  537.            )
  538.    )
  539. )
  540. )
  541. ;;; Set the prompt string
  542. (defun cht_SetPrompt ()
  543. (if (= typ "Style")
  544.    (progn
  545.      (initget "Individual List New Select ")
  546.      (setq nw (getkword (strcat "\nIndividual/List/Select style/<"
  547.                                 prmpt
  548.                                 " for all text objects" ">: ")))
  549.      (if (or (= nw "") (= nw nil) (= nw "Enter"))
  550.        (setq nw (getstring (strcat prmpt
  551.                                    " for all text objects" ": ")))
  552.      )
  553.    )
  554.    (progn
  555.      (initget "List Individual" 1)
  556.      (setq nw (getreal (strcat "\nIndividual/List/<"
  557.                                 prmpt
  558.                                 " for all text objects" ">: ")))
  559.    )
  560. )
  561. )
  562. ;;; Process List request
  563. (defun cht_ProcessList ()
  564. (setq unctr (1- unctr))
  565. (setq sslen (sslength sset))
  566. (setq tw 0)
  567. (while (> sslen 0)
  568.    (setq temp (ssname sset (setq sslen (1- sslen))))
  569.    (if (= typ "Style")
  570.      (progn
  571.        (if (= tw 0)
  572.          (setq tw (list (cdr (assoc fld (entget temp)))))
  573.          (progn
  574.            (setq sty (cdr (assoc fld (entget temp))))
  575.            (if (not (member sty tw))
  576.              (setq tw (append tw (list sty)))
  577.            )
  578.          )
  579.        )
  580.      )
  581.      (progn
  582.        (setq tw (+ tw (setq w (cdr (assoc fld (entget temp))))))
  583.        (if (= (sslength sset) (1+ sslen)) (setq lw w hw w))
  584.        (if (< hw w) (setq hw w))
  585.        (if (> lw w) (setq lw w))
  586.      )
  587.    )
  588. )
  589. (if (= typ "Rotation")
  590.    (setq tw (* (/ tw pi) 180.0)
  591.          lw (* (/ lw pi) 180.0)
  592.          hw (* (/ hw pi) 180.0))
  593. )
  594. (if (= typ "Style")
  595.    (progn
  596.      (princ (strcat "\n" typ "(s) -- "))
  597.      (princ tw)
  598.    )
  599.    (princ (strcat "\n" typ
  600.             " -- Min: " (rtos lw 2)
  601.             "\t Max: " (rtos hw 2)
  602.             "\t Avg: " (rtos (/ tw (sslength sset)) 2) ) )
  603. )
  604. )
  605. ;;; Process Individual request
  606. (defun cht_ProcessIndividual ()
  607. (setq sslen (sslength sset))
  608. (while (> sslen 0)
  609.    (setq temp (ssname sset (setq sslen (1- sslen))))
  610.    (setq ow (cdr (assoc fld (entget temp))))
  611.    (if (= typ "Rotation")
  612.      (setq ow (/ (* ow 180.0) pi))
  613.    )
  614.    (initget 0)
  615.    (redraw (cdr (assoc -1 (entget temp))) 3)
  616.    (if (= typ "Style")
  617.      (progn
  618.        (setq nw (getstring (strcat "\n" prmpt " <" ow ">: ")))
  619.      )
  620.      (progn
  621.        (setq nw (getreal (strcat "\n" prmpt " <" (rtos ow 2) ">: ")))
  622.      )
  623.    )
  624.    (if (or (= nw "") (= nw nil))
  625.      (setq nw ow)
  626.    )
  627.    (if (= typ "Rotation")
  628.      (setq nw (* (/ nw 180.0) pi))
  629.    )
  630.    (entmod (subst (cons fld nw)
  631.                   (assoc fld (setq ent (entget temp)))
  632.                   ent
  633.            )
  634.    )
  635.    (redraw (cdr (assoc -1 (entget temp))) 1)
  636. )
  637. )
  638. ;;; Process the Select option
  639. (defun cht_ProcessSelect ()
  640. (princ "\nSearch for which Style name?  <*>: ")
  641. (setq sn  (xstrcase (getstring))
  642.        n   -1
  643.        nsset (ssadd)
  644.        ssl (1- (sslength sset))
  645.        )
  646. (if (or (= sn "*") (null sn) (= sn ""))
  647.    (setq nsset sset sn "*")
  648.    (while (and sn (< n ssl))
  649.      (setq temp (ssname sset (setq n (1+ n))))
  650.      (if (= (cdr (assoc 7 (entget temp))) sn)
  651.        (ssadd temp nsset)
  652.      )
  653.    )
  654. )
  655. (princ (strcat "\nStyle: " sn))
  656. (print (setq ssl (sslength nsset)))
  657. (princ "objects found.")
  658. )
  659. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  660. ;;; and then try to load it.  If it can't be found or can't be
  661. ;;; loaded, then abort the loading of this file immediately.
  662. (cond
  663. ((and ai_dcl (listp ai_dcl)))                ; it's already loaded.
  664. ((not (findfile "ai_utils.lsp"))                ; find it
  665.    (ai_abort "CHT" nil)
  666. )
  667. ((eq "failed" (load "ai_utils" "failed"))        ; load it
  668.    (ai_abort "CHT" nil)
  669. )
  670. )
  671. ;;; If we get this far, then AI_UTILS.LSP is loaded and it can
  672. ;;; be assumed that all functions defined therein are available.
  673. ;;; Next, check to see if ACADAPP.EXP has been xloaded, and abort
  674. ;;; if the file can't be found or xloaded.  Note that AI_ACADAPP
  675. ;;; does not abort the running application itself (so that it can
  676. ;;; also be called from within the command without also stopping
  677. ;;; an AutoCAD command currently in progress).
  678. (if (not (ai_acadapp)) (ai_abort "CHT" nil))
  679. ;;; The C: function definition
  680. (defun c:cht () (cht_Main))
  681. (princ "\n\tCHT command loaded.")
  682. (princ)
回复

使用道具 举报

6

主题

15

帖子

9

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 16:07:33 | 显示全部楼层
谢谢,我会的。
回复

使用道具 举报

6

主题

15

帖子

9

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 16:08:38 | 显示全部楼层
或者,有没有办法在命令行上使用FIND命令,因为这样可以解决我的文本替换要求?
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:21:08 | 显示全部楼层
很抱歉没有时间调试Autodesk的Express Tools。。。这看起来只是改变了文本属性?如果是这样,请考虑选择文字,然后使用“特性”选项板执行相同的操作。
  1. (defun c:foo (/ s)
  2. (if (setq s (ssget ":L" '((0 . "text"))))
  3.    (progn (sssetfirst nil s) (vl-cmdf "_.properties"))
  4. )
  5. (princ)
  6. )
回复

使用道具 举报

6

主题

15

帖子

9

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 16:27:10 | 显示全部楼层
没关系,我不希望你也这样。我假设问题是如何加载lisp,而不是lisp本身,否则我不会问。
谢谢你的剧本,我来试试。
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:31:30 | 显示全部楼层
也许可以尝试加载“CHT”,尽管如果你在命令行中键入expresstools,我认为所有这些东西都是自动加载的?
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 16:39:22 | 显示全部楼层
请阅读代码发布指南,并编辑代码以包含在代码标签中。[NOPARSE]
  1. Your Code Here[/NOPARSE]
=
  1. Your Code Here
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:43:57 | 显示全部楼层
您的加载语法正确,将代码粘贴到vlide,并且它报告了lisp代码中的错误,因此加载失败。
 
不幸的是,需要检查代码。
 
根据Ronjonp的说法,你与另一个命令有冲突
 
发现它(defun c:chtt()(cht_Main))有效,不要使用cht、CT或CTX
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-2 15:12 , Processed in 0.903476 second(s), 72 queries .

© 2020-2025 乐筑天下

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