乐筑天下

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

[编程交流] 有可能把这些结合起来吗

[复制链接]

1

主题

61

帖子

65

银币

初来乍到

Rank: 1

铜币
4
发表于 2022-7-6 10:37:07 | 显示全部楼层 |阅读模式
将这两个编号lisp例程结合起来会很困难吗?我想画一个多边形周围的数字和TXT。我已经能够想出如何编辑这些,但运气不好,并结合这些功能。
 
 
  1. ; inserts increasing numbers inside polygon
  2. (defun c:iwn (/ p n ni ts oecho ds th txt na)
  3. (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
  4. (setq th (getvar "dimtxt"))
  5. (setq txt (* th ds))
  6. (setq ts txt)
  7. (if nn (setq nn (fix nn))(setq nn 1))
  8. (if (= nn 0)(setq nn 1))
  9. (princ "\n Increment by < ")
  10. (princ nn)
  11. (princ " >? : ")
  12. (setq ni (getint))
  13. (if (= ni nil)(setq ni nn)(setq nn ni))
  14. (if np
  15.    ()
  16.    (setq np 1)
  17. )
  18. (princ "\n Start or continue with number < ")
  19. (princ np)
  20. (princ " >? : ")
  21. (setq n (getint))
  22. (if (= n nil)
  23.    (setq n np)
  24.    (setq np n)
  25. )
  26. (setq p (getpoint "\n Number location: "))
  27. (setq oecho (getvar "cmdecho"))
  28. (setvar "cmdecho" 0)
  29. (while p
  30.    (setq na (itoa n))
  31.    (entmake (list (cons 0 "TEXT")
  32.      (cons 10 p)
  33.      (cons 11 p)
  34.      (cons 1 na); actual text
  35.      (cons 7 (getvar "TEXTSTYLE"))
  36.      (cons 40 txt)
  37.      (cons 72 4)
  38.       )
  39.     )
  40.    (if (> n 99)
  41.      (command "polygon" "5" p "c" (* ts 1.4))     ; edit for number of polygon sides
  42.      (command "polygon" "5" p "c" (* ts 1.4)))    ; edit for number of polygon sides
  43.    (setq p (getpoint "\n Next number location: ")
  44.   n (+ ni n)
  45.   np n
  46.    )
  47. )
  48. (setvar "cmdecho" oecho)
  49. (princ)
  50. )
  51. (princ "\n Type > iwn <  to insert numbers inside hexagon")

 
第二个允许前缀和后缀TXT。
 
 
  1. ;;; TX+INTEGERS+TX
  2. (defun c:tit (/ p n ni pref suff nns ntx ntxx oecho osn ds th txt)
  3. (setq oecho (getvar "cmdecho")
  4. osn   (getvar "osmode")
  5. )
  6. (if (= 0 (getvar "dimscale"))(setq ds 1.0)(setq ds (getvar "dimscale")))
  7. (setq th (getvar "dimtxt"))
  8. (setq txt (* th ds))
  9. (setvar "cmdecho" 0)
  10. (setvar "osmode" 0)
  11. (if nn
  12.    (setq nn (fix nn))
  13.    (setq nn 1)
  14. )
  15. (if (= nn 0)(setq nn 1))
  16. (princ "\n Increment numbers by < ")
  17. (princ nn)
  18. (princ " >? : ")
  19. (setq ni (getint))
  20. (if (= ni nil)
  21.    (setq ni nn)
  22.    (setq nn ni)
  23. )
  24. (if np
  25.    (setq np (fix np))
  26.    (setq np nn)
  27. )
  28. (princ "\n Start or continue with number < ")
  29. (princ np)
  30. (princ " >? : ")
  31. (setq n (getint))
  32. (if (= n nil)
  33.    (setq n np)
  34.    (setq np n)
  35. )
  36. (setq nns (itoa n))
  37. (princ "\n Prefix text < ")
  38. (princ pre)
  39. (princ " >? or <.> for none: ")
  40. (setq pref (getstring t))
  41. (if (= pref ".")
  42.    (progn
  43.      (setq pre nil)
  44.      (setq pref nil)
  45.    )
  46.    (progn
  47.      (if (= pref "")
  48. (setq pref pre)
  49. (setq pre pref)
  50.      )
  51.      (if pref
  52.   (setq ntx (strcat pref nns))
  53.      )
  54.    )
  55. )
  56. (princ "\n Suffix text < ")
  57. (princ suf)
  58. (princ " >? or <.> for none: ")
  59. (setq suff (getstring t))
  60. (if (= suff ".")
  61.    (progn
  62.      (setq suf nil)
  63.      (setq suff nil)
  64.    )
  65.    (progn
  66.      (if (= suff "")
  67. (setq suff suf)
  68. (setq suf suff)
  69.      )
  70.      (if suff
  71. (if pref
  72.   (setq ntxx (strcat pref nns suff))
  73.   (setq ntxx (strcat nns suff))
  74. )
  75.      )
  76.    )
  77. )
  78. (setq p (getpoint "\n Insert: "))
  79. (setq oecho (getvar "cmdecho"))
  80. (while p
  81.    (if suff
  82.      ;(command "text" "j" "mc" p "" "" ntxx)
  83.      (entmake (list (cons 0 "TEXT")
  84.       (cons 10 p)
  85.       (cons 11 p)
  86.       (cons 1 ntxx) ; actual text
  87.       (cons 7 (getvar "TEXTSTYLE"))
  88.       (cons 40 txt)
  89.       (cons 72 4)
  90.        )
  91.      )
  92.      (if pref
  93. ;(command "text" "j" "mc" p "" "" ntx)
  94. (entmake (list (cons 0 "TEXT")
  95.      (cons 10 p)
  96.      (cons 11 p)
  97.      (cons 1 ntx); actual text
  98.      (cons 7 (getvar "TEXTSTYLE"))
  99.      (cons 40 txt)
  100.      (cons 72 4)
  101.       )
  102.     )
  103. ;(command "text" "j" "mc" p "" "" n)
  104. (entmake (list (cons 0 "TEXT")
  105.      (cons 10 p)
  106.      (cons 11 p)
  107.      (cons 1 n); actual text
  108.      (cons 7 (getvar "TEXTSTYLE"))
  109.      (cons 40 txt)
  110.      (cons 72 4)
  111.       )
  112.     )
  113.      )
  114.    )
  115.    (setq p   (getpoint "\n Next number location: ")
  116.   n   (+ ni n)
  117.   nns (itoa n)
  118.   np n
  119.    )
  120.    (if suff
  121.      (if pref
  122. (setq ntxx (strcat pref nns suff))
  123. (setq ntxx (strcat nns suff))
  124.      )
  125.    )
  126.    (if pref
  127.      (if suff
  128. (setq ntxx (strcat pref nns suff))
  129. (setq ntx (strcat pref nns))
  130.      )
  131.    )
  132. )
  133. (setvar "cmdecho" oecho)
  134. (setvar "osmode" osn)
  135. (princ)
  136. )
  137. (princ "\n Type > TIT <  to insert text with ascending integers.")
回复

使用道具 举报

4

主题

24

帖子

16

银币

初来乍到

Rank: 1

铜币
27
发表于 2022-7-6 10:57:53 | 显示全部楼层
嗨,戈斯特里德,
测试这个代码也许你想这样
  1. (defun c:test (/ ds n ni nn nns np ntx ntxx oecho osn p pre pref suf suff th ts txt)
  2.   (setq oecho (getvar "cmdecho"))
  3.   (if
  4.      (/= oecho 0)
  5.      (setvar "cmdecho" 0)
  6.      ) ; if
  7.   (setq osn (getvar "osmode"))
  8.   (if
  9.      (= 0 (getvar "dimscale"))
  10.      (setq ds 1.0)
  11.      (setq ds (getvar "dimscale"))
  12.      ) ; if
  13.   (setq th (getvar "dimtxt"))
  14.   (setq txt (* th ds))   
  15.   (setq ts txt)   
  16.   (setvar "cmdecho" 0)
  17.   (setvar "osmode" 0)
  18.   (if
  19.      nn
  20.      (setq nn (fix nn))
  21.      (setq nn 1)
  22.      ) ; if
  23.   (if (= nn 0)(setq nn 1))
  24.   (setq ni (getint (strcat "\n Increment numbers by < " (itoa nn) " >? : ")))
  25.   (if
  26.      (= ni nil)
  27.      (setq ni nn)
  28.      (setq nn ni)
  29.      ) ; if
  30.   (if
  31.      np
  32.      (setq np (fix np))
  33.      (setq np nn)
  34.      ) ; if
  35.   (setq n (getint (strcat "\n Start or continue with number < " (itoa np) " >? : ")))
  36.   (if
  37.      (= n nil)
  38.      (setq n np)
  39.      (setq np n)
  40.      ) ; if
  41.   (setq nns (itoa n))
  42.   (setq pre "A")
  43.   (setq pref (getstring t (strcat "\n Prefix text < " pre " >? or <.> for none: "))) ; ??!!
  44.   (if
  45.      (= pref ".")
  46.      (progn
  47.         (setq pre nil)
  48.         (setq pref nil)
  49.         ) ; progn
  50.      (progn
  51.         (if (= pref "")
  52.            (setq pref pre)
  53.            (setq pre pref)
  54.            ) ; if
  55.         (if pref
  56.            (setq ntx (strcat pref nns))
  57.            ) ; if
  58.         )    ; progn
  59.      )       ; if
  60.   (setq suf "Z")
  61.   (setq suff (getstring t (strcat "\n Suffix text < " suf " >? or <.> for none: ")))
  62.   (if
  63.      (= suff ".")
  64.      (progn
  65.         (setq suf nil)
  66.         (setq suff nil)
  67.         ) ; progn
  68.      (progn
  69.         (if (= suff "")
  70.            (setq suff suf)
  71.            (setq suf suff)
  72.            ) ; if
  73.         (if suff
  74.            (if pref
  75.               (setq ntxx (strcat pref nns suff))
  76.               (setq ntxx (strcat nns suff))
  77.               ) ; if
  78.            )    ; if
  79.         )       ; progn
  80.      )          ; if
  81.   (setq p (getpoint "\n Insert: "))
  82.   (while
  83.      p
  84.      (if
  85.         suff
  86.         (entmake (list (cons 0 "TEXT")
  87.                        (cons 10 p)
  88.                        (cons 11 p)
  89.                        (cons 1 ntxx) ; actual text
  90.                        (cons 7 (getvar "TEXTSTYLE"))
  91.                        (cons 40 txt)
  92.                        (cons 72 4)))
  93.         (if
  94.            pref
  95.            (entmake (list (cons 0 "TEXT")
  96.                           (cons 10 p)
  97.                           (cons 11 p)
  98.                           (cons 1 ntx); actual text
  99.                           (cons 7 (getvar "TEXTSTYLE"))
  100.                           (cons 40 txt)
  101.                           (cons 72 4)))
  102.            (entmake (list (cons 0 "TEXT")
  103.                           (cons 10 p)
  104.                           (cons 11 p)
  105.                           (cons 1 n); actual text
  106.                           (cons 7 (getvar "TEXTSTYLE"))
  107.                           (cons 40 txt)
  108.                           (cons 72 4)))
  109.            ) ; if
  110.         )    ; if
  111.      (command "polygon" "5" p "c" (* ts 1.5))
  112.      (setq p (getpoint "\n Next number location: "))
  113.      (setq n (+ ni n))
  114.      (setq nns (itoa n))
  115.      (if
  116.         suff
  117.         (if
  118.            pref
  119.            (setq ntxx (strcat pref nns suff))
  120.            (setq ntxx (strcat nns suff))
  121.            ) ; if
  122.         )    ; if
  123.      (if
  124.         pref
  125.         (if
  126.            suff
  127.            (setq ntxx (strcat pref nns suff))
  128.            (setq ntx (strcat pref nns))
  129.            ) ; if
  130.         )    ; if
  131.      )       ; while
  132.   (setvar "cmdecho" oecho)
  133.   (setvar "osmode" osn)
  134.   (princ)
  135.   )
回复

使用道具 举报

1

主题

61

帖子

65

银币

初来乍到

Rank: 1

铜币
4
发表于 2022-7-6 11:15:39 | 显示全部楼层
阿,非常感谢你抽出时间为我做这件事。我经常用这个。我以为我能弄明白,但这比我所理解的要先进一点。
它工作得很好。。。
回复

使用道具 举报

4

主题

24

帖子

16

银币

初来乍到

Rank: 1

铜币
27
发表于 2022-7-6 11:22:11 | 显示全部楼层
不客气
回复

使用道具 举报

6

主题

30

帖子

24

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 11:44:41 | 显示全部楼层
很好,非常感谢
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-6 08:35 , Processed in 0.929787 second(s), 62 queries .

© 2020-2025 乐筑天下

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