Jump to content

Measure along a complex line


Recommended Posts

I have a complex line made up of lines and arcs (a roadway baseline). The complex line is intersected by two other lines.


How do I measure the distance along the complex line between the two intersections?


MicroStation has a very useful "measure along" tool for this. I have not been able to find a tool in AutoCAD to do this.

Screenshot 2024-02-21 163349.jpg

Link to comment
Share on other sites

You need to run a function twice so get the distance from the start of a pline to where 1st line crosses, then do again for 2nd line crossing distance = dist1-dist2


(setq pt1 (vlax-invoke obj2 'intersectWith obj1 acExtendThisEntity))

(setq dist1 (vlax-curve-getdistatpoint obj pt1))

(setq pt2 (vlax-invoke obj3 'intersectWith obj1 acExtendThisEntity))

(setq dist2 (vlax-curve-getdistatpoint obj pt2))


Another way is trim the pline using the 2 crossing lines, get the remaining pline  length, then do Undo to restore pline.


You are correct as far as I know no built in function but an easy task manually or lisp.


Link to comment
Share on other sites

Use DIST command and select first point, then Multiple points, then measure the straight portion, then Arc and measure the arc.


It seems to fail if starting in a non-end snap part of the arc, other than that seem to work, though the total is on the commandline. 


You might look into the DIST command in Help, maybe I don't remember all of the options.


As BIGAL shows, a custom LISP my suit your needs better.


Maybe let us know what AutoCAD version you are using and post a .dwg.


I moved the thread to the AutoLISP, Visual LISP & DCL Forum, to see if a LISP solution works better.

Link to comment
Share on other sites

Perhaps this?

(defun draw_pt (pt / pt1 pt2 pt3 pt4)
    rap (/ (getvar "viewsize") 100)
    pt1 (list (+ (car pt) rap) (+ (cadr pt) rap) (caddr pt))
    pt2 (list (+ (car pt) rap) (- (cadr pt) rap) (caddr pt))
    pt3 (list (- (car pt) rap) (- (cadr pt) rap) (caddr pt))
    pt4 (list (- (car pt) rap) (+ (cadr pt) rap) (caddr pt))
  (grdraw pt pt1 -1)
  (grdraw pt pt2 -1)
  (grdraw pt pt3 -1)
  (grdraw pt pt4 -1)
(defun c:dist_curv (/ ss pt en dxf_11 d_curv)
  (princ "\nSelect a curvilinear object.")
  (while (setq ss (ssget "_+.:E:S" '((0 . "*LINE,ARC,CIRCLE,ELLIPSE") (-4 . "<NOT") (0 . "MLINE") (-4 . "NOT>"))))
    (while (setq pt (getpoint "\nGive a reference point to measure the curvilinear distance: "))
      (setq dxf_11 (vlax-curve-getClosestPointTo (setq en (ssname ss 0)) (trans pt 1 0)))
      (draw_pt (trans dxf_11 0 1))
      (initget 1)
      (setq pt2 (getpoint "\nGive a point for measurement: "))
      (setq pt2 (vlax-curve-getClosestPointTo en (trans pt2 1 0)))
      (setq d_curv (abs (- (vlax-curve-getDistAtPoint en dxf_11) (vlax-curve-getDistAtPoint en pt2))))
      (draw_pt (trans pt2 0 1))
      (princ (strcat "\nSegment length " (rtos d_curv) "over a total length of "(rtos (vlax-curve-getDistAtPoint en (vlax-curve-getEndPoint en)))))


Link to comment
Share on other sites

Thanks for all the good info!


I'm new to AutoCAD. I work in transportation and we use MicroStation for almost everything.


I'll be checking out this LISP stuff soon to try and learn how to incorporate it into my workflow. Measuring between two points on a roadway baseline is a very common task for me.

Link to comment
Share on other sites

Try this expects a crossing object so dont pick say intersection.


(defun c:d2 ( / obj1 obj2 obj3 intpt1 intp2 d1 d2)
(setq obj1 (vlax-ename->vla-object (car  (entsel "Pick line/pline/arc "))))
(setq obj2 (vlax-ename->vla-object (car  (entsel "Pick 1st crossing line/pline/arc "))))
(setq obj3 (vlax-ename->vla-object (car  (entsel "Pick 2nd crossing line/pline/arc "))))
(setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendnone))
(setq intpt2 (vlax-invoke obj3 'intersectWith obj1 acExtendnone))
(setq d1 (vlax-curve-getdistatpoint obj1 intpt1))
(setq d2 (vlax-curve-getdistatpoint obj1 intpt2))
(alert (strcat "Distance is " (rtos (abs (- d2 d1)) 2 3)))



Almost forgot you can take this lisp and use Appload save to Startup suite then is ready all the time. I load a lisp on startup with about 30 defuns common stuff used all the time. Or add to the Pop menu, Toolbar menu or Ribbon. I would strongly suggest if your going to add lots more functions that you make Custom menu's dont add to the default Acad etc.


Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...