乐筑天下

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

[编程交流] 管道破裂符号lisp需要e

[复制链接]

28

主题

130

帖子

126

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
154
发表于 2022-7-6 17:23:05 | 显示全部楼层 |阅读模式
大家好,下面为管道和钢型材绘制了断裂标记-它仅适用于线条。
 
如何将其更改为同时处理多段线??
 
这是一个老Lisp程序,已经坐了一段时间了。
干杯
 
 
  1. (defun c:SHS () (endsym "SHS") (princ))
  2. (defun c:CHS () (endsym "CHS") (princ))
  3. (defun drchs (en1 pt1 en2 pt2 dpt / a12 d12 hd12 qd12 bulge mpt a1p a2p)
  4. (setq a12 (angle pt1 pt2)   
  5.        d12 (distance pt1 pt2)   
  6.        hd12 (* 0.5 d12)
  7.        qd12 (* 0.25 d12)
  8.        bulge (* 0.35 qd12)
  9.        mpt (polar pt1 a12 hd12)
  10. )
  11. (if (is_left pt1 pt2 dpt)
  12.    (progn
  13.      (setq a1p (polar (polar pt1 a12 qd12) (+ a12 (dtr 90)) bulge)
  14.            a2p (polar (polar mpt a12 qd12) (+ a12 (dtr 90)) bulge)
  15.      )
  16.    )
  17.    (progn
  18.      (setq a1p (polar (polar pt1 a12 qd12) (- a12 (dtr 90)) bulge)
  19.            a2p (polar (polar mpt a12 qd12) (- a12 (dtr 90)) bulge)
  20.      )
  21.    )
  22. )
  23. (command "PLINE" pt1 "A" "S" a1p mpt pt2 "S" a2p mpt "")
  24. )
  25. ;To draw a break symbol
  26. (defun endsym (typ / ce en1 en2 pt1 pt2 ed1 ed2 mpt lay lt col draw dpt)
  27. (setq typ (strcat typ))
  28. (princ (strcat "\n" typ " End"))
  29. (setq *olderror* *error* *error* *brkerr*)
  30. (setq ce (getvar "CMDECHO"))
  31. (setvar "CMDECHO" 0)
  32. (setq en1 (pickline "Pick point on 1st line" "QUI,NEA")
  33.        en2 (pickline "Pick 2nd line" "QUI,PER")
  34.        pt1 (cadr en1)        en1 (car en1)
  35.        pt2 (cadr en2)        en2 (car en2)
  36.        ed1 (entget en1)      ed2 (entget en2)
  37.        mpt (polar pt1 (angle pt1 pt2) (* 0.5 (distance pt1 pt2)))
  38. )
  39. (grdraw pt1 pt2 -1) (setq draw T)
  40. (initget 1)
  41. (setq dpt (getpoint "\nPick side to break: " mpt))
  42. (grdraw pt1 pt2 -1) (setq draw nil)
  43. (setq lay (getvar "CLAYER") lt (getvar "CELTYPE") col (getvar "CECOLOR"))
  44. (setvar "CLAYER" (dxf 8 ed1))
  45. (setvar "CELTYPE" (if (setq elt (dxf 6 ed1)) elt "BYLAYER"))
  46. (setvar "CECOLOR" (if (setq ec (dxf 62 ed1)) (itoa ec) "BYLAYER"))
  47. (command ".UNDO" "GROUP")
  48. (trimline ed1 pt1 pt2 dpt)
  49. (trimline ed2 pt2 pt1 dpt)
  50. (cond
  51.    ((= typ "SHS") (drshs ed1 pt1 ed2 pt2 dpt))
  52.    ((= typ "CHS") (drchs ed1 pt1 ed2 pt2 dpt))
  53.    (T (princ (strcat "\nInvalid end type: " typ)))
  54. )
  55. (command ".UNDO" "END")
  56. (setvar "CLAYER" lay)
  57. (setvar "CELTYPE" lt)
  58. (setvar "CECOLOR" col)
  59. (setvar "CMDECHO" ce)
  60. (setq *error* *olderror* *olderror* nil)
  61. (princ)
  62. )
  63. ;Tests to see if a point is to the left of a line.  The first two points
  64. ;represent the sp and ep of the line and pt is the point to test.  If pt
  65. ;is ON the line then this says it is NOT left.  Returns T or nil
  66. (defun is_left (sp ep pt / ase aes asp)
  67. (setq ase (angle sp ep)
  68.        aes (angle ep sp)
  69.        asp (angle sp pt)
  70. )
  71. (cond
  72.    ((= ase 0.0) (if (< asp pi) T nil))
  73.    ((= ase pi) (if (> asp pi) T nil))
  74.    ((< ase pi) (if (and (> asp ase) (< asp aes)) T nil))
  75.    (T (if (or (> asp ase) (< asp aes)) T nil))
  76. )
  77. )
  78. (defun drshs (ed1 pt1 ed2 pt2 dpt / a12 d12 pt3 pt4)
  79. (setq a12 (angle pt1 pt2)   d12 (distance pt1 pt2))
  80. (if (is_left pt1 pt2 dpt)
  81.    (setq pt3 (polar pt2 (- a12 (* 0.5 pi)) (* d12 0.25)))
  82.    (setq pt3 (polar pt2 (+ a12 (* 0.5 pi)) (* d12 0.25)))
  83. )
  84. (setq pt4 (polar pt1 (angle pt1 pt3) (* 0.5 (distance pt1 pt3))))
  85. (command "LINE" pt1 pt3 "")
  86. (command "LINE" pt2 pt4 "")
  87. )
  88. (defun trimline (ed pt1 pt2 dpt / sp)
  89. (setq sp (dxf 10 ed))
  90. (if (is_left pt1 pt2 dpt)
  91.    (if (is_left pt1 pt2 sp)
  92.      (setq ed (chged ed 10 pt1))
  93.      (setq ed (chged ed 11 pt1))
  94.    )
  95.    (if (is_left pt1 pt2 sp)
  96.      (setq ed (chged ed 11 pt1))
  97.      (setq ed (chged ed 10 pt1))
  98.    )
  99. )
  100. (entmod ed)
  101. )
  102. ;To pick a line using OSNAP mode os (string).  Returns the same as entsel
  103. (defun pickline (prm os / oldos en ed typ)
  104. (if (not os) (setq os "NONE"))
  105. (while (not en)
  106.    (if (setq en (entsel (strcat "\n" prm ": ")))
  107.      (progn
  108.        (setq typ (dxf 0 (entget (car en))))
  109.        (if (/= typ "LINE")
  110.          (progn
  111.            (setq en nil)
  112.            (princ (strcat "\nInvalid selected entity: " typ))
  113.          )
  114.        )
  115.      )
  116.    )
  117. )
  118. (list
  119.    (car en)
  120.    (setvar "LASTPOINT" (osnap (cadr en) os))
  121. )
  122. )
  123. (defun *brkerr* (msg)
  124. (if draw (grdraw pt1 pt2 -1))
  125. (if ce (setvar "CMDECHO" ce))
  126. (if pw (setvar "PLINEWID" pw))
  127. (if lay (setvar "CLAYER" lay))
  128. (if col (setvar "CELTYPE" col))
  129. (if lt (setvar "CECOLOR" lt))
  130. (setq *error* *olderror* *olderror* nil)
  131. (princ)
  132. )
  133. (defun dxf (code ed)
  134. (cdr (assoc code ed))
  135. )
  136. (defun dtr (ang)
  137. (* pi (/ ang 180.0))
  138. )
  139. (defun rtd (ang)
  140. (* 180.0 (/ ang pi))
  141. )
  142. (defun dwgscl (d)
  143. (* d (getvar "DIMSCALE"))
  144. )
  145. (defun chged (ed code new)
  146. (subst (cons code new) (assoc code ed) ed)
  147. )
  148. (princ)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 15:40 , Processed in 0.312748 second(s), 54 queries .

© 2020-2025 乐筑天下

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