乐筑天下

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

[编程交流] 请用双线Lisp程序

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:26:46 | 显示全部楼层 |阅读模式
 
我已经绘制了一个网络
我想把一行转换成两行
 
-----------------------------------------------------------

==============================================
 
有人能帮我吗
回复

使用道具 举报

57

主题

351

帖子

294

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
285
发表于 2022-7-6 14:47:02 | 显示全部楼层
为什么不只是抵消?
回复

使用道具 举报

57

主题

351

帖子

294

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
285
发表于 2022-7-6 15:10:00 | 显示全部楼层
这将让你追踪你已经拥有的线路,但是作为2条线路,你最多可以做16条线路,我从ASMI那里得到的
  1. ;; ============================================================ ;;
  2. ;;                                                              ;;
  3. ;;  MPL.LSP - This lisp draws 2 - 16 polylines simultaneously ;;
  4. ;;                                                             ;;
  5. ;; ============================================================ ;;
  6. ;;                                                             ;;
  7. ;;  Command(s) to call: MPL                            ;;
  8. ;;                                                           ;;
  9. ;;  Instead standard options  instead you can use the short     ;;
  10. ;;  options consisting of quantity of polylines (from 2 to 16)  ;;
  11. ;;  and justification (Top, Zero, Bottom). For example:        ;;
  12. ;;                                                             ;;
  13. ;;  Command: mpl                                             ;;
  14. ;;  <<< Quantity = 12, Justification = Top, Offset = 40 >>>  ;;
  15. ;;  Specify first point or [Quantity/Justification/Offset]: 6  ;;
  16. ;;  <<< Quantity = 6, Justification = Top, Offset = 40 >>>  ;;
  17. ;;                                                             ;;
  18. ;;  Command: mpl                                             ;;
  19. ;;  <<< Quantity = 6, Justification = Top, Offset = 40 >>>  ;;
  20. ;;  Specify first point or [Quantity/Justification/Offset]: B  ;;
  21. ;;  <<< Quantity = 6, Justification = Bottom, Offset = 40 >>>  ;;
  22. ;;                                                             ;;
  23. ;;  Command: mpl                                             ;;
  24. ;;  <<< Quantity = 6, Justification = Top, Offset = 40 >>>  ;;
  25. ;;  Specify first point or [Quantity/Justification/Offset]: 16z ;;
  26. ;;  <<< Quantity = 16, Justification = Zero, Offset = 40 >>>  ;;
  27. ;;                                                             ;;
  28. ;; ============================================================ ;;
  29. ;;                                                              ;;
  30. ;;  THIS PROGRAM AND PARTS OF IT MAY REPRODUCED BY ANY METHOD ;;
  31. ;;  ON ANY MEDIUM FOR ANY REASON. YOU CAN USE OR MODIFY THIS ;;
  32. ;;  PROGRAM OR PARTS OF IT ABSOLUTELY FREE.                  ;;
  33. ;;                                                              ;;
  34. ;;  THIS PROGRAM PROVIDES THIS PROGRAM 'AS IS' WITH ALL FAULTS ;;
  35. ;;  AND SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  ;;
  36. ;;  MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.            ;;
  37. ;;                                                             ;;
  38. ;; ============================================================ ;;
  39. ;;                                                              ;;
  40. ;;  V1.3, 12 May, 2005, Riga, Latvia                            ;;
  41. ;;  © Aleksandr Smirnov (ASMI)                           ;;
  42. ;;  For AutoCAD 2000 - 2008 (isn't tested in a next versions) ;;
  43. ;;                                                              ;;
  44. ;;                             [url]http://www.asmitools.com[/url]    ;;
  45. ;;                                                             ;;
  46. ;; ============================================================ ;;
  47. (defun c:mpl(/ ptOpt oldQuont oldJust oldOff stPt mlName lastEnt
  48.               firEnt lnSet oldEcho rLst *error*)
  49. (vl-load-com)
  50. (defun asmi-mlStyleCreate(Quont / dxfLst topOrd Count mlDict)
  51. (setq dxfLst
  52.   (list'(0 . "MLINESTYLE")'(102 . "{ACAD_REACTORS")'(102 . "}")
  53.    '(100 . "AcDbMlineStyle")(cons 2(strcat(itoa Quont)"_PLINES"))
  54.    '(70 . 0)'(3 . "")'(62 . 256)'(51 . 1.5708)'(52 . 1.5708)
  55.     (cons 71 Quont))
  56.        Count 0.0
  57.        topOrd(-(/ Quont 2.0) 0.5)
  58.       ); end setq
  59. (repeat Quont
  60.     (setq dxfLst(append dxfLst
  61.                   (list(cons 49(- topOrd Count))
  62.                     '(62 . 256) '(6 . "BYLAYER")))
  63.           Count(1+ Count)
  64.    );end setq
  65.    ); end repeat
  66.    (if
  67.     (null
  68.       (member
  69.        (assoc 2 dxfLst)(dictsearch(namedobjdict)"ACAD_MLINESTYLE")))
  70.          (progn
  71.             (setq mlDict
  72.      (cdr
  73.        (assoc -1
  74.   (dictsearch(namedobjdict)"ACAD_MLINESTYLE"))))
  75.              (dictadd mlDict(cdr(assoc 2 dxfLst))(entmakex dxfLst))
  76.     ); end progn
  77.     ); end if
  78.      (strcat(itoa Quont)"_PLINES")
  79.    ); end of asmi-mlStyleCreate
  80. (defun asmi-LayersUnlock(/ restLst)
  81.    (setq restLst '())
  82.    (vlax-for lay(vla-get-Layers
  83.        (vla-get-ActiveDocument
  84.          (vlax-get-acad-object)))
  85.            (setq restLst
  86.              (append restLst
  87.        (list
  88.   (list lay (vla-get-Lock lay)
  89.         ); end list
  90.   ); end list
  91.        ); end append
  92.    ); end setq
  93.       (vla-put-Lock lay :vlax-false)
  94.     ); end vlax-for
  95.   restLst
  96. ); end of asmi-LayersUnlock
  97. (defun asmi-LayersStateRestore(StateList)
  98.    (foreach lay StateList
  99.       (vla-put-Lock(car lay)(cadr lay))
  100.      ); end foreach
  101.    (princ)
  102.   ); end of asmi-LayersStateRestore
  103. (defun ExplodeMline()
  104.   (setvar "CMDECHO" 0)
  105.   (if(or(not lastEnt)(not(equal lastEnt(entlast))))
  106.       (setq lastEnt(entlast))
  107.       (setq lastEnt nil)
  108.     ); end if
  109. (if lastEnt
  110.    (progn
  111.      (setq rLst(asmi-LayersUnlock))
  112.      (command "_.explode" lastEnt)
  113.      (setq lnSet(ssadd))
  114.      (ssadd
  115.        (setq lastEnt
  116.          (entnext lastEnt))lnSet); end setq
  117.    (while
  118.      (setq lastEnt(entnext lastEnt))
  119.       (if lastEnt(ssadd lastEnt lnSet))
  120.     ); end while
  121. (cond
  122.    ((or
  123.       (and lnSet(not(getvar "PEDITACCEPT")))
  124.       (and lnSet(=(getvar "PEDITACCEPT")0))
  125.       ); end or
  126.    (command "_.pedit" "_m" lnSet "" "_y" "_j" "0.0" "")
  127.     ); end condition #1
  128.    ((and lnSet(=(getvar "PEDITACCEPT")1))
  129.     (command "_.pedit" "_m" lnSet "" "_j" "0.0" "")
  130.      ); end condition #2
  131.    ); end cond
  132.    (asmi-LayersStateRestore rLst)
  133.    (setvar "CMDECHO" oldEcho)
  134.    ); end progn
  135.   ); end if
  136. ); end of ExplodeMline
  137. (defun *error*(msg)
  138.    (ExplodeMline)
  139.    (if rLst
  140.      (asmi-LayersStateRestore rLst)
  141.      ); end if
  142.      (if odlEcho
  143. (setvar "CMDECHO" odlEcho)
  144. ); end if
  145.    (princ)
  146.    ); end of *error*
  147. (if(not mpl:quont)(setq mpl:quont 2))
  148. (if(not mpl:just)(setq mpl:just "Zero"))
  149. (if(not mpl:off)(setq mpl:off 40.0))
  150. (setq ptOpt T
  151.        oldQuont mpl:quont
  152.        oldJust mpl:just
  153.        oldOff mpl:Off
  154.        oldEcho(getvar "CMDECHO")
  155. ); end setq
  156. (while(and ptOpt(/= 'LIST (type ptOpt)))
  157.   (princ
  158.     (strcat "\n<<< Quantity = " (itoa mpl:quont)
  159.             ", Justification = " mpl:just
  160.             ", Offset = " (rtos mpl:off) " >>> "
  161.      ); end strcat
  162.     ); end princ
  163.   (initget 128)
  164.    (setq ptOpt
  165.     (getpoint
  166.       (strcat "\nSpecify first point or [Quantity/Justification/Offset]: ")))
  167.         (if(=(type ptOpt) 'STR)
  168.            (setq ptOpt(strcase ptOpt))
  169.           ); end if
  170.    (cond
  171.       ((= 'LIST(type ptOpt))
  172.       (setq stPt ptOpt)
  173.       (princ "\nSpecify next point or [undo]: ")
  174.       ); end condition #1
  175.      ((= ptOpt "Q")
  176.       (setq mpl:quont
  177.       (getint
  178.          (strcat "\nSpecify quantity from 2 to 16 <"(itoa mpl:quont)">: ")))
  179.           (if(null mpl:quont)(setq mpl:quont oldQuont))
  180.           (if(or(< mpl:quont 2)(> mpl:quont 16))
  181.              (progn
  182.                (setq mpl:quont oldQuont)
  183.                (princ "\n<!> Only from 2 to 16 polylines are available <!> ")
  184.              ); end progn
  185.            ); end if
  186.       ); end condition #2
  187.      ((= ptOpt "J")
  188.        (initget "Zero Top Bottom")
  189.         (setq mpl:just
  190.             (getkword
  191.                (strcat "\nSpecify justification [Zero/Top/Bottom] <" mpl:just ">: ")))
  192.                (if(null mpl:just)(setq mpl:just oldJust))
  193.        ); end condition #4
  194.      ((= ptOpt "O")
  195.       (initget 2)
  196.       (setq mpl:off
  197.        (getdist
  198.          (strcat "\nSpecify offset distance <" (rtos mpl:off) ">: ")))
  199.            (if(null mpl:off)(setq mpl:off oldOff))
  200.       ); end condition #5
  201.      ((if(member ptOpt
  202.             '("2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16"))
  203.           (setq mpl:quont(atoi ptOpt))
  204.        ); end if
  205.       ); end condition #6
  206.      ((if(member ptOpt
  207.             '("Z" "T" "B"))
  208.           (setq mpl:just(cadr
  209.                (assoc(strcase ptOpt)
  210.                '(("Z" "Zero")("T" "Top")("B" "Bottom"))))
  211.                ); end setq
  212.        ); end if
  213.       ); end condition #7
  214.      ((if(member ptOpt
  215.        '("2Z" "2T" "2B" "3Z" "3T" "3B" "4Z" "4T" "4B" "5Z" "5T" "5B"
  216.          "6Z" "6T" "6B" "7Z" "7T" "7B" "8Z" "8T" "8B" "9Z" "9T" "9B"
  217.          "10Z" "10T" "10B" "11Z" "11T" "11B" "12Z" "12T" "12B"
  218.          "13Z" "13T" "13B" "14Z" "14T" "14B" "15Z" "15T" "15B"
  219.          "16Z" "16T" "16B"))
  220.      (setq mpl:quont
  221.             (atoi(substr ptOpt 1(1-(strlen ptOpt))))
  222.            mpl:just(cadr
  223.             (assoc(substr(strcase ptOpt)(strlen ptOpt)1)
  224.             '(("Z" "Zero")("T" "Top")("B" "Bottom"))))
  225.            ); end setq
  226.         ); end if
  227.       ); end condition #8
  228.         ((if ptOpt(princ "\n<!> Invalid option keyword <!> "))
  229.          ); end condition #9
  230.         ); end cond
  231.       ); end while
  232.    (if ptOpt
  233.       (progn
  234.        (setq mlName(asmi-mlStyleCreate mpl:quont))
  235.   (if(entlast)
  236.       (setq lastEnt(entlast))
  237.    ); end if
  238. (setvar "cmdecho" 0)
  239. (command "_.mline"
  240.           "_ST" mlName
  241.           "_S" mpl:off
  242.           "_J" (strcat "_" mpl:just)
  243.         stPt)
  244. (setvar "CMDECHO" 1)
  245.       (while(= 1(getvar "CMDACTIVE"))
  246.          (command pause)
  247.        ); end while
  248. (setvar "CMDECHO" 0)
  249. (ExplodeMline)
  250. ); end progn
  251. ); end if
  252. (princ)
  253. ); end of c:mpl
  254. (princ "\n*** To draw simultaneously from 2 up to 16 polylines type MPLINE *** ")
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-6 15:41:02 | 显示全部楼层
可以使用多行命令并节省很多麻烦。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 00:18 , Processed in 0.319646 second(s), 60 queries .

© 2020-2025 乐筑天下

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