;比例分布による任意点高さの計算と表記
;+++++++++++++
(defun C:CODE21mm ()
;+++++++++++++
    (Command "OsnapCoord" "1" "-Layer" "M" "FlagID" "" )
    (setq Pt1 (getpoint "\n1点目を指定："))
    (Command "ID" Pt1)
    (setq Pt1x (nth 0 Pt1))
    (setq Pt1y (nth 1 Pt1))
    (setq Pt1z (getstring "\n1点目高さを入力："))
    ;+++++++++++++
    (setq Pt1xn (/ Pt1x 1000)
            Pt1yn (/ Pt1y 1000))
    (setq Pt1xn (rtos Pt1xn )
            Pt1yn (rtos Pt1yn ))
    ;+++++++++++++
    (Command "Ucs" "w" 
                   "-MText" "@" "J" "ML" "H" (getVar "Dimtxt") "@0,0" 
                   (Strcat "X="  (rtos Pt1xn)) (Strcat "Y=" (rtos Pt1yn))  (Strcat "Z=" Pt1z) ""
                  "Grips" "2"	
                  "Ucs" "p")
    ;----
    (setq Pt2 (getpoint "\n2点目を指定："))
    (Command "ID" Pt2)
    (setq Pt2x (nth 0 Pt2))
    (setq Pt2y (nth 1 Pt2))
    (setq Pt2z (getstring "\n2点目高さを入力："))
    ;+++++++++++++
    (setq Pt2xn (/ Pt2x 1000)
            Pt2yn (/ Pt2y 1000))
    (setq Pt2xn (rtos Pt2xn )
            Pt2yn (rtos Pt2yn ))
    ;+++++++++++++
    (Command "Ucs" "w" 
            "-MText" "@" "J" "ML" "H" (getVar "Dimtxt") "@0,0" 
            (Strcat "X="  (rtos Pt2xn)) (Strcat "Y=" (rtos Pt2yn))  (Strcat "Z=" Pt2z) ""
            "Grips" "2"	
            "Ucs" "p")
    ;----
    (setq Pt (getpoint "\n計測する位置を指定："))
    (Command "ID" Pt)
    (setq Ptx (nth 0 Pt))
    (setq Pty (nth 1 Pt))
    (setq dx (- Pt2x  Pt1x )
            dy (- Pt2y  Pt1y )
            dz (- (atof Pt2z ) (atof Pt1z ))
            Lx (- Ptx Pt1x)
            Ly (- Pty Pt1y))
    (if (/= 0 dx)
        (setq Delta (/ dz dx)
                Ptz (+ (atof Pt1z ) (* Delta Lx)))
        (setq Delta (/ dz dy)
                Ptz (+ (atof Pt1z ) (* Delta Ly)))
    );if
    (Command "Leader" Pt "_non" Pause "a"
            (Strcat "X="  (rtos Ptx)) (Strcat "Y=" (rtos Pty))  (Strcat "Z=" (rtos Ptz)) ""
           "Grips" "2");
    (princ)
)
