There are no elevation differences -- everything's at Z=0. Do you mean you want to get the numerical difference between the content of two Text objects, or Attributes?
for blocks
(abs (- (atof (getpropertyvalue (car (entsel "\nPick block 1: ")) "1950.550")) (atof (getpropertyvalue (car (entsel "\nPick block 2: ")) "1950.550"))))
for texts
(abs (- (atof (getpropertyvalue (car (entsel "\nPick text mark 1: ")) "textstring")) (atof (getpropertyvalue (car (entsel "\nPick text mark 2: ")) "textstring"))))
maybe like that
(defun c:get_elev_difference (/ elevation_offset_sset ename_1 ename_2)
(prompt "\nPick 2 entities with marked elevation offset.")
(setq elevation_offset_sset (ssget '((0 . "insert,text"))))
(if (and elevation_offset_sset
(= 2 (sslength elevation_offset_sset))
)
(abs (- (if (= "INSERT" (cdr (assoc 0 (entget (setq ename_1 (ssname elevation_offset_sset 0))))))
(atof (getpropertyvalue ename_1 "1950.550"))
(atof (getpropertyvalue ename_1 "textstring"))
)
(if (= "INSERT" (cdr (assoc 0 (entget (setq ename_2 (ssname elevation_offset_sset 1))))))
(atof (getpropertyvalue ename_2 "1950.550"))
(atof (getpropertyvalue ename_2 "textstring"))
)
)
)
(progn
(princ "\nInvalid selection")
(princ)
)
)
)
hey there,
try this one
(defun c:get_elev_difference (/ elevation_offset_sset ename_1 ename_2)
(arxload "geomcal.crx")
(prompt "\nPick 2 entities with marked elevation offset.")
(setq elevation_offset_sset (ssget '((0 . "insert,text"))))
(if (and elevation_offset_sset
(= 2 (sslength elevation_offset_sset))
)
(abs (- (if (= "INSERT" (cdr (assoc 0 (entget (setq ename_1 (ssname elevation_offset_sset 0))))))
(cal (getpropertyvalue ename_1 "1950.550"))
(cal (getpropertyvalue ename_1 "textstring"))
)
(if (= "INSERT" (cdr (assoc 0 (entget (setq ename_2 (ssname elevation_offset_sset 1))))))
(cal (getpropertyvalue ename_2 "1950.550"))
(cal (getpropertyvalue ename_2 "textstring"))
)
)
)
(progn
(princ "\nInvalid selection")
(princ)
)
)
)
updated
sometimes I get this error.
; error: no function definition: CAL
I had this working. but right now it's not working. I wonder what is the reason?
----------------------
I think I should run the Cal command first in Command... then it works
Ok. I understood thank you.
******************************************
There is only one problem:
5+800.00
4+195.00
In texts like this, it only gives the difference as 606. However, the correct result (according to this process) should be 1606. How do we organize this?
sometimes even ;
KM 5+800.00
KM 4+195.00
It can also be like...
for these check the following code
(defun c:get_elev_difference (/ elevation_offset_sset ename_1 ename_2)
(defun string_number (string)
(if (vl-string-search "+" string)
(setq string (vl-string-subst "" "+" string))
)
(if (vl-string-search "KM" string)
(setq string (vl-string-subst "" "KM" string))
)
(atof string)
)
(prompt "\nPick 2 entities with marked elevation offset.")
(setq elevation_offset_sset (ssget '((0 . "insert,text"))))
(if (and elevation_offset_sset
(= 2 (sslength elevation_offset_sset))
)
(abs (- (if (= "INSERT" (cdr (assoc 0 (entget (setq ename_1 (ssname elevation_offset_sset 0))))))
(string_number (getpropertyvalue ename_1 "1950.550"))
(string_number (getpropertyvalue ename_1 "textstring"))
)
(if (= "INSERT" (cdr (assoc 0 (entget (setq ename_2 (ssname elevation_offset_sset 1))))))
(string_number (getpropertyvalue ename_2 "1950.550"))
(string_number (getpropertyvalue ename_2 "textstring"))
)
)
)
(progn
(princ "\nInvalid selection")
(princ)
)
)
)