Print Page | Close Window

Determine Distance Between Points On An Entity

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=12445
Printed Date: 31.May.2026 at 22:28


Topic: Determine Distance Between Points On An Entity
Posted By: utkub
Subject: Determine Distance Between Points On An Entity
Date Posted: 18.Aug.2017 at 00:39
Hi everyone,

Attached lisp is writen by Alan Thompson and then modifed by another developer.

This lisp calculates the distance between two points along an object (line, circle, arc, polyline, spline, etc.) and writes the distance on second point.

But it takes too much time while using this lisp for 2 or more times on same object. Because you have to restart the procedure for each point pair.

Can this lisp upgradeable like this;
  1. first, we will choose a start point on an object,
  2. then lisp will write the distance which is between start point and n'th point, on n'th point.

So we will choose start point only once and then lisp will write the distance on all next points which we click on the object.

Thanks for help,

uploads/740357/DistanceBetweenPoints2.rar" rel="nofollow -



Replies:
Posted By: Kent Cooper
Date Posted: 23.Aug.2017 at 18:01
Something like this, perhaps:

(vl-load-com)
(defun C:MDFR (/ esel path refdist pt); = Mark Distance(s) From Reference location
  (setq
    esel (entsel "\nSelect object at reference location: ")
    path (car esel)
    refdist (vlax-curve-getDistAtPoint path (vlax-curve-getClosestPointTo path (cadr esel)))
  ); setq
  (while
    (setq pt (getpoint "\nLocation to mark distance from reference: "))
    (command "_.text" ; current Layer & other properties -- could do Mtext instead
      "_mc" "_none" (vlax-curve-getClosestPointTo path pt); middle-center justification
      "" 0 ; current non-fixed-height Style, current height, 0 rotation
      (rtos (abs (- (vlax-curve-getDistAtPoint path ins) refdist))); in current units format & precision
    ); command
  ); while
);defun

It is minimally tested, and assumes certain things, which you can adjust for as you prefer.

It does not have the usual controls yet [error handling, verification that you picked an object that has distance along it, or that subsequent picks are along the same object, Undo start/end, etc.], but see what you think.



Print Page | Close Window