Jump to content

Distance from given reference


Recommended Posts

Hello guys!

I am trying to get the distance from one point to another, then add it to the given reference as part of a text in the drawing. (The text format is "Ref. 364.80", for example).

I have searched over the other topics and this is what I found:




Also, my drawings are all scaled 1:100, so the distance must be divided by 10 before adding the reference cote.


Here is the screenshot:



Thank you!

Link to comment
Share on other sites

This is what you want it is metric.


;Calculates level of a point in cross or long sections
; BY alanh 2014

(setvar "cmdecho" 0)

(princ "\n To run just type SRL")

;;-------------------=={ Parse Numbers }==--------------------;;`
;;                                                            ;;
;;  Parses a list of numerical values from a supplied string. ;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;  Returns:  List of numerical values found in string.       ;;

(defun LM:ParseNumbers ( s )
    (lambda ( l )
        (strcat "("
                (lambda ( a b c )
                      (< 47 b 58)
                      (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                      (and (= 46 b) (< 47 a 58) (< 47 c 58))
                    b 32
              (cons nil l) l (append (cdr l) (list nil))
    (vl-string->list s)

(defun c:SRL ()
(setq olddimzin (getvar "dimzin"))
(setvar "dimzin" 0)
(if (= dwgscale nil)
(setq dwgscale (/ 1000.0 (getreal "\n enter vertical scale ")))
;(setq datum (getreal "\n Enter datum level "))
(setq datum (car (LM:ParseNumbers (cdr (assoc 1 (entget (car (entsel "\nPick datum text"))))))))

(setq test 1)
(setq pt1 (cadr (getpoint "\npick datum")))
(while (= test 1)

(setq pt2 (cadr (getpoint "\npick point")))

(setq dist (/(abs (- pt1 pt2)) dwgscale))

      (setq en1 (car (entsel "\nSelect text number:" )))
      (if (/= en1 nil)
        (setq tent (entget en1))
        (setq a (+ dist datum))
        (setq a (rtos a 2 3))
        (setq el (subst (cons 1 a) (assoc 1 tent) tent))
        (entmod el)
       (princ "\nplease pick again"); else
); while t

(setq el nil
 en nil
a nil
en1 nil
test nil)

(setvar "cmdecho" 1)
(setvar "dimzin" olddimzin)
)	;ends main defun


  • Like 1
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...