Display full version of the post: Determine Distance Between Points On An Entity

utkub
18.08.2017, 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;first, we will choose a start point on an object,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

Kent Cooper
23.08.2017, 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);defunIt 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.
Kent Cooper2017-08-23 19:50:38