Elevation difference

Elevation difference

k005
Advisor Advisor
1,104 Views
15 Replies
Message 1 of 16

Elevation difference

k005
Advisor
Advisor

Hello friends;


How can I get the elevation differences of the objects I have given in the sample drawing (2 separate objects) on the command line?


Thanks in advance to the helpful friend.

 

 

 

Accepted solutions (3)
1,105 Views
15 Replies
Replies (15)
Message 2 of 16

Kent1Cooper
Consultant
Consultant

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?

Kent Cooper, AIA
Message 3 of 16

komondormrex
Mentor
Mentor

 

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"))))

 

Message 4 of 16

k005
Advisor
Advisor

Yes. I definitely mean the numerical difference. My goal is to make the attribute process even if it is a block or text.

0 Likes
Message 5 of 16

k005
Advisor
Advisor

Thanks. How can we combine these codes in a single select object?

0 Likes
Message 6 of 16

k005
Advisor
Advisor

The result of both selections should be: 2.60.


Atr.Block in some projects. In some, it is just text.


My goal is to be able to do this in a single routine.

0 Likes
Message 7 of 16

komondormrex
Mentor
Mentor
Accepted solution

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)
		 )
 	)
)

 

 

Message 8 of 16

k005
Advisor
Advisor

Ok. Thank you very much, well done. 🤗

 

 

 

 

0 Likes
Message 9 of 16

k005
Advisor
Advisor

Hello


How can we make this lisp code capable of processing texts such as 4+382, 4+391?

 @komondormrex 

0 Likes
Message 10 of 16

komondormrex
Mentor
Mentor
Accepted solution

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

 

Message 11 of 16

k005
Advisor
Advisor

Thank you buddy. ‌🤗 internet connection was very slow. Now I can write...

0 Likes
Message 12 of 16

k005
Advisor
Advisor

@komondormrex 

 

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

 

 

0 Likes
Message 13 of 16

komondormrex
Mentor
Mentor

geomcal.crx got unloaded. check update or load cal manually (arxload "geomcal.crx").

Message 14 of 16

k005
Advisor
Advisor

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...

 

 

 

0 Likes
Message 15 of 16

komondormrex
Mentor
Mentor
Accepted solution

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)
		 )
	)
)
Message 16 of 16

k005
Advisor
Advisor

Thank you very much. Ok. 🤗

0 Likes