乐筑天下

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

[编程交流] 第二条路线的链测长度

[复制链接]

15

主题

315

帖子

361

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 23:31:14 | 显示全部楼层
我想这就是你想要的。
(如果不是,它会按照我上一篇文章的建议做)
 
命令:PERP
 
最后,查看命令栏:您将获得交点列表(具有次曲线的连接线)。
我只是不知道你对这些观点的意图是什么。
 
(星期一之前你不会收到我的来信)
 
  1. ;; @file: measure a curved line; every 500 units draw a perpendicular line.  We are looking for the intersection of the perpendicular lines with a second curved line
  2. ;; @author: Emmanuel Delay - emmanueldelay@gmail.com
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;; resources ...
  5. (vl-load-com)
  6. (setq modelSpace (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object))))
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ;; main function
  9. (defun perp (dist / curve-obj curve-second points xlines intersections)
  10. (setq
  11.    curve-obj (entsel "\n Select a curve:")                             ;; client selects the curved object, to be measured
  12.    curve-second (entsel "\n Select a second curve:")                   ;; client selects the second object;
  13.    points (getMeasurePoints dist curve-obj)                            ;; list of all the points.  From those points we draw the perpendicular lines
  14.    xlines (drawPerpendicularLines points curve-obj curve-second)       ;; Construction lines (xline)
  15.    intersections (getIntersections xlines curve-second)                ;; returns a list of intersection points
  16. )
  17. (princ "\nIntersection points:\n")
  18. (princ intersections)
  19. )
  20. ;; measures a polyline, returns a list of points, all "dist" away from each other, along the curve
  21. (defun getMeasurePoints (dist curve / points needle pt)
  22. (setq
  23.    needle dist
  24.    points (list)
  25.    pt nil
  26. )
  27. (while (and                                                           ;; repeat while vlax-curve-getPointAtDist keeps finding a new point
  28.      (setq pt (vlax-curve-getPointAtDist (car curve) needle))
  29.      (/= nil pt)
  30.    )
  31.      (setq
  32.        points (append points (list pt))
  33.      )
  34.      (setq needle (+ needle dist))
  35. )
  36. points
  37. )
  38. (defun drawPerpendicularLines (points curve curve-second / i pt p xlines vl-obj x)
  39. (setq
  40.    i 0
  41.    xlines (list)
  42. )
  43. (repeat (length points)
  44.    (setq pt (nth i points))
  45.    (setq vl-obj (vlax-ename->vla-object (car curve)))
  46.    (setq x
  47.      (vlax-curve-getParamAtPoint vl-obj
  48.        (setq
  49.          p (vlax-curve-getClosestPointTo vl-obj pt)
  50.         )
  51.      )
  52.    )
  53.    (setq xlines (append
  54.      xlines
  55.      (list (drawPerpendicularLine curve curve-second x pt))
  56.    ))
  57.    (setq i (+ i 1))
  58. )
  59. xlines
  60. )
  61. (defun drawPerpendicularLine (curve curve-second param pt / deriv PTDERIV ptg xline)
  62. ;; @see http://cadxp.com/topic/21475-vlax-curve-getfirstderiv/
  63. (setq deriv (vlax-curve-getFirstDeriv (vlax-ename->vla-object (car curve)) param))
  64. (setq PTDERIV (mapcar '+ pt deriv))
  65. ;; get a point, distance 10000.0, angle: perpendicular
  66. (setq ptg (polar pt (+ (angle pt PTDERIV) (/ pi 2)) 10000.00))
  67. (setq xline (drawXline ptg pt))
  68. xline
  69. )
  70. (defun getIntersections (xlines curve-second / i intersects)
  71. (setq
  72.    i 0
  73.    intersects (list)
  74. )
  75. (repeat (length xlines)
  76.    (setq intersects (append intersects (list
  77.      (vlax-invoke
  78.        (nth i xlines)
  79.        'IntersectWith
  80.        (vlax-ename->vla-object (car curve-second))
  81.      3)
  82.    )))
  83.    (setq i (+ i 1))
  84. )
  85. intersects
  86. )
  87. (defun drawXline (p1 p2)
  88. (vla-AddXline modelSpace (vlax-3d-point p1) (vlax-3d-point p2))
  89. )
  90. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  91. ;; command PERP
  92. (defun c:perp ( / )
  93. (perp 500)
  94. (princ)
  95. )
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-5 23:37:48 | 显示全部楼层
 
  1. (defun c:pso ( / cl1 cl2  d  pt pt2 templine ang spc )
  2. ;;;                pBe 30Aug2014                ;;;
  3.         (if (and
  4.       (princ "\nSelect the main alignment")
  5.       (setq cl1 (ssget "_:S" '((0 . "*POLYLINE"))))
  6.       (princ "\nSelect the offset alignment")
  7.       (setq cl2 (ssget "_:S" '((0 . "*POLYLINE"))))
  8.       )
  9. (progn
  10. [color="blue"] (setq d (cond ((getdist
  11.        (strcat "\nEnter increment value: " " <" (rtos (setq d
  12.              (cond ( d_ ) ( 100.00 ))
  13.            ) 2 2) ">: ")))
  14.    ( d )
  15. )
  16.      )[/color]
  17.   (setq cl1 (ssname cl1 0)
  18.         cl2 (ssname cl2 0) d_ d)
  19.   (while (setq pt (vlax-curve-getpointatdist cl1 d))
  20.             (setq ang (angle '(0.0 0.0 0.0)
  21.                          (vlax-curve-getfirstderiv
  22.                            cl1
  23.                            (vlax-curve-getparamatpoint cl1 pt)
  24.                          )
  25.                   )
  26.         )
  27.             (setq templine        (vlax-invoke (setq spc (vlax-get
  28.                            (vla-get-ActiveLayout
  29.                       (vla-get-ActiveDocument (vlax-get-acad-object )))
  30.                                              'Block)) '[color="blue"]AddXline[/color] pt
  31.           (polar pt (setq ang (+ ang  (* pi 1.5))) 1))
  32.         )
  33.         (if (setq pt2 (vlax-invoke
  34.                         templine
  35.                         'IntersectWith
  36.                         (vlax-ename->vla-object cl2)
  37.                         0
  38.                       )
  39.             )
  40.            [color="red"] (vlax-invoke  spc 'Addline pt (list (Car pt2)(cadr pt2)(caddr pt2)))[/color]
  41.         )
  42.     (vla-delete templine)
  43.     (setq d (+ d d_))
  44.     )
  45.   )
  46.   )
  47.   (princ)
  48.   )
  49. (vl-load-com)

 
命令:pso
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 06:15 , Processed in 0.915666 second(s), 54 queries .

© 2020-2025 乐筑天下

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