Author Topic: [AcGe(4)] The shortest distance and position between any two curves  (Read 368 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 514
Topic: Looking for closest points between two polylines
https://www.theswamp.org/index.php?topic=50829.0



ARX



Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ()
  2.   (if (and (setq e1 (xdrx-entsel "\nPick first curve<exit>:" '((0 . "*line,arc,ellipse,circle"))))
  3.            (setq p1 (cadr e1)
  4.                  e1 (car e1)
  5.            )
  6.            (setq e2 (xdrx-entsel "\nPick second curve<exit>:" '((0 . "*line,arc,ellipse,circle"))))
  7.            (setq p2 (cadr e2)
  8.                  e2 (car e2)
  9.            )
  10.            (setq g1 (xdge::constructor e1))
  11.            (setq g2 (xdge::constructor e2))
  12.            (setq p1 (xdge::getpropertyvalue g1 "ClosestPointTo" p1))
  13.            (setq p2 (xdge::getpropertyvalue g2 "ClosestPointTo" p2))
  14.            (setq pt1 (xdge::constructor "kpointoncurve3d"))
  15.            (setq pt2 (xdge::constructor "kpointoncurve3d"))
  16.            (setq a (xdge::getpropertyvalue
  17.                      g1 "getClosestPointto" g2 pt1 pt2)
  18.            )
  19.       )
  20.     (progn
  21.       (xdrx-begin)
  22.       (xdrx-line-make
  23.         (setq p1 (xdge::getpropertyvalue (car a) "point"))
  24.         (setq p2 (xdge::getpropertyvalue (cadr a) "point"))
  25.       )
  26.       (xd::pnt:mark p1 2 0.008)
  27.       (xd::pnt:mark p2 2 0.008)
  28.       (xdrx-prompt (xdrx-string-format "\n####Two Curve ClosestDistance is: %.2f ####" (distance p1 p2)))
  29.       (xdrx-end)
  30.     )
  31.   )
  32.   (princ)
  33. )
« Last Edit: December 11, 2023, 09:47:10 AM by xdcad »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net