;MEASURE2 - measure distance from both ends to the midpoint of a curve (set PDMODE to view results)
;7/2007 XANADU, www.xanadu.cz

(vl-load-com)

(defun C:MEASURE2 ( / ocmd entl ent2 obj ptS ptE ptM dst)
  (setq ocmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384))
  (if (setq ent1 (entsel "Select object to measure: "))
    (progn
     (setq obj (vlax-ename->vla-object (car ent1))
           ptS (vlax-curve-getStartPoint obj)
           ptE (vlax-curve-getEndPoint obj)
           ptM (vlax-curve-getPointAtDist obj (* 0.5 (vlax-curve-getDistAtPoint obj ptE))); 50% of the length = MID
           ptS (trans ptS 0 1); to UCS
           ptM (trans ptM 0 1)
     )
     (command "_.BREAK" ent1 "_F" ptM ptM)
     (setq ent2 (entlast))
     (initget 7)
     (setq dst (getdist "\nMeasure distance: "))
     (command "._MEASURE" (list (car ent1) ptS) dst)
     (command "._MEASURE" (list ent2 ptE) dst)
    ));if progn
  (setvar "CMDECHO" ocmd)
  (setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384))
  (princ)
)
