乐筑天下

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

[编程交流] 中间的一系列多段线

[复制链接]

20

主题

62

帖子

42

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 23:12:01 | 显示全部楼层 |阅读模式
我需要一个lisp,它将在两个边界多段线之间绘制一系列多段线。多段线序列将与两条边界多段线垂直。请查看图片。
 
001206iq7fruqk7ut4r2aj.jpg
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-5 23:26:53 | 显示全部楼层
下面是一个示例代码,用于在
  1. ;; written by Fatty T.O.H. ()2005 * all rights removed
  2. ;; edited 5/14/12
  3. ;; draw perpendicular lines
  4. ;;load ActiveX library
  5. (vl-load-com)
  6. ;;local defuns
  7. ;;//
  8. (defun start (curve)
  9. (vl-catch-all-apply (function (lambda()
  10. (vlax-curve-getclosestpointto curve
  11. (vlax-curve-getstartpoint curve
  12.    )
  13. )
  14. )
  15.    )
  16. )
  17. )
  18. ;;//
  19. (defun end (curve)
  20. (vl-catch-all-apply (function (lambda()
  21. (vlax-curve-getclosestpointto curve
  22. (vlax-curve-getendpoint curve
  23.    )
  24. )
  25. )
  26.    )
  27. )
  28. )
  29. ;;//
  30. (defun pointoncurve (curve pt)
  31. (vl-catch-all-apply (function (lambda()
  32. (vlax-curve-getclosestpointto curve
  33. pt
  34.    )
  35. )
  36. )
  37.    )
  38. )
  39. ;;//
  40. (defun paramatpoint (curve pt)
  41. (vl-catch-all-apply (function (lambda()
  42. (vlax-curve-getparamatpoint curve
  43. pt
  44.    )
  45. )
  46. )
  47.    )
  48. )
  49. ;;//
  50. (defun distatpt (curve pt)
  51. (vl-catch-all-apply (function (lambda()
  52. (vlax-curve-getdistatpoint curve
  53.    (vlax-curve-getclosestpointto curve pt)
  54.    )
  55. )
  56.    )
  57.    )
  58. )
  59. ;;//
  60. (defun pointatdist (curve dist)
  61. (vl-catch-all-apply (function (lambda()
  62. (vlax-curve-getclosestpointto curve
  63. (vlax-curve-getpointatdist curve dist)
  64.    )
  65. )
  66. )
  67.    )
  68. )
  69. ;;//
  70. (defun curvelength (curve)
  71. (vl-catch-all-apply (function (lambda()
  72. (vlax-curve-getdistatparam curve
  73. (- (vlax-curve-getendparam curve)
  74.     (vlax-curve-getstartparam curve)
  75.    )
  76. )
  77. )
  78. )
  79.    )
  80. )
  81. ;;//
  82. (defun distatparam (curve param)
  83. (vl-catch-all-apply (function (lambda()
  84. (vlax-curve-getdistatparam curve
  85. param
  86. )
  87. )
  88.    )
  89.    )
  90. )
  91. ;;// written by VovKa (Vladimir Kleshev)
  92. (defun gettangent (curve pt)
  93. (setq param (paramatpoint curve pt)
  94.        ang ((lambda (deriv)
  95.     (if (zerop (cadr deriv))
  96.       (/ pi 2)
  97.       (atan (apply '/ deriv))
  98.     )
  99.   )
  100.    (cdr (reverse
  101.    (vlax-curve-getfirstderiv curve param)
  102.         )
  103.    )
  104. )
  105. )
  106. ang
  107. )
  108. ;;// main program
  109. ;;--------------------------------------------------;;
  110. (defun c:DIP (/ *error* acsp adoc cnt div en en2 ent ent2 ip lastp leng ln lnum mul num pt rot sign start step)
  111. (defun *error* (msg)
  112.      (vla-endundomark (vla-get-activedocument
  113.              (vlax-get-acad-object))
  114.       )
  115.    (cond ((or (not msg)
  116.        (member msg '("console break" "Function cancelled" "quit / exit abort"))
  117.        )
  118.    )
  119.   ((princ (strcat "\nError: " msg)))
  120.   )
  121.    (princ)
  122.    )
  123. (setq adoc (vla-get-activedocument (vlax-get-acad-object))
  124.    acsp (vla-get-block (vla-get-activelayout adoc))
  125.     )
  126. (while (not
  127.   (and
  128.     (or
  129.       (initget 6)
  130.       (setq step (getreal "\nEnter step <25>: "))
  131.       (if (not step)
  132. (setq step 25.)))
  133.     ))
  134.   (alert "\nEnter a step")
  135.   )
  136. (if (and
  137. (setq
  138.    ent (entsel
  139.   "\nSelect curve near to the start point >>"
  140.   )
  141.    )
  142. (setq
  143.    ent2 (entsel
  144.   "\nSelect other curve  >>"
  145.   )
  146.    )
  147. )
  148.   (progn
  149.     (setq en (car ent)
  150.    pt (pointoncurve en (cadr ent))
  151.    leng (distatparam en (vlax-curve-getendparam en))
  152.    en2 (car ent2)
  153.    )
  154.     (setq num (fix (/ leng step))
  155.    )
  156.     (setq div (fix (/ 100. step)
  157.      )
  158.    )
  159.     (setq mul (- leng
  160.    (* (setq lnum (fix (/ leng (* step div)))) (* step div))))
  161.     (if (not (zerop mul))
  162.       (setq lastp T)
  163.       (setq lastp nil)
  164.       )
  165.     (if (> (- (paramatpoint en pt)
  166.        (paramatpoint en (vlax-curve-getstartpoint en))
  167.        )
  168.     (- (paramatpoint en (vlax-curve-getendpoint en))
  169.        (paramatpoint en pt)
  170.        )
  171.     )
  172.       (progn
  173. (setq start leng
  174.        sign  -1
  175.        )
  176. )
  177.       (progn
  178. (setq start (distatparam en (vlax-curve-getstartparam en))
  179.        sign  1
  180.        )
  181. )
  182.       )
  183.     (vla-startundomark
  184.       (vla-get-activedocument (vlax-get-acad-object))
  185.       )
  186.     (setq cnt 0)
  187.     (repeat (1+ num)
  188.       (setq pt  (pointatdist en start)
  189.      rot (gettangent en pt)
  190.      )
  191. (setq ln (vlax-invoke-method acsp 'addline (setq ip (vlax-3d-point pt))(vlax-3d-point(pointoncurve en2 pt))))
  192.       (setq cnt   (1+ cnt)
  193.      start (+ start (* sign step))
  194.      )
  195.       )
  196.     (if lastp
  197.       (progn
  198. (if (= sign -1)
  199.    (progn
  200.      (setq pt  (vlax-curve-getstartpoint en)
  201.     rot (gettangent en pt)
  202.     )
  203.      )
  204.    (progn
  205.      (setq pt  (vlax-curve-getendpoint en)
  206.     rot (gettangent en pt)
  207.     )
  208.      )
  209.    )
  210. (setq ln (vlax-invoke-method acsp 'addline (setq ip (vlax-3d-point pt))(vlax-3d-point(pointoncurve en2 pt))))
  211. )
  212.       )
  213.     )
  214.   (princ "\nNothing selected")
  215.   )
  216. (*error* nil)
  217. (princ)
  218. )
  219. (prompt "\n   >>>   Type DIP to execute...")
  220. (prin1)

 
~'J'~
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 23:31:18 | 显示全部楼层
除非多段线平行,否则多段线之间的一系列直线只能垂直于其中一条多段线。
回复

使用道具 举报

6

主题

249

帖子

247

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-5 23:38:35 | 显示全部楼层
代码很好,胖子!读你的代码我学到了很多!
史蒂夫
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-5 23:48:39 | 显示全部楼层
您还可以在2条样条线之间进行规则漫游,然后提取点值-大卫
回复

使用道具 举报

20

主题

62

帖子

42

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-5 23:55:56 | 显示全部楼层
 
 
谢谢fixo的代码。非常感谢。
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 00:01:18 | 显示全部楼层
很高兴你成功了,
干杯
 
~'J'~
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 00:07:59 | 显示全部楼层
谢谢Steve,
很高兴我能帮上忙,
当做
 
~'J'~
回复

使用道具 举报

7

主题

33

帖子

26

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 00:15:12 | 显示全部楼层
fixo公司
请在主题上帮助我
 
提前谢谢你
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 03:06 , Processed in 0.406360 second(s), 73 queries .

© 2020-2025 乐筑天下

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