Jump to content

lisp routine that will difference in elevation between two points.


sigi-19

Recommended Posts

I'm looking for a lisp routine that will difference in elevation between two points.

 

It would need to work as such:

1: select a point 1,

2: select point 2.

than routin will Calculate the difference between

(z)point 1 to (z) point 2

 

and Write the result Where the user Request

Link to comment
Share on other sites

KISS principle

 

(setq Pt1 (getpoint))
(setq pt2 (getpoint))
(setq X1 (nth 0 pt1))
(setq y1 (nth 1 pt1))
(setq Z1 (nth 2 pt1 ))
(setq X2 (nth 0 pt1))
(setq y2 (nth 1 pt1))
(setq Z2 (nth 2 pt1 ))
(princ (- z2 z1))

Link to comment
Share on other sites

Thanks Thread

 

Thank you

 

I made some changes

 

The third step is to write the answer on the drawing

 

What is the correct command for this?

 

(defun c:Z-h ()

(setq Pt1 (getpoint))

(setq pt2 (getpoint))

(setq X1 (nth 0 Pt1))

(setq y1 (nth 1 Pt1))

(setq Z1 (nth 2 Pt1))

(setq X2 (nth 0 pt2))

(setq y2 (nth 1 pt2))

(setq Z2 (nth 2 pt2))

(princ (- z1 z2))

(princ)

;finish cleanly

 

) ;end of defun

 

sigi-19

Link to comment
Share on other sites

Just add this line (presuming your current text style doesn't have imposed height):

...
(princ (- z1 z2))
[color=blue](command "_TEXT" pause "" "" (rtos (- z1 z2)))[/color]
(princ)
...

 

Please edit your previous post and add the required code tags.

Link to comment
Share on other sites

hi

i insert the code

 

(defun c:Z-h1 ()

(setq Pt1 (getpoint))

(setq pt2 (getpoint))

(setq X1 (nth 0 Pt1))

(setq y1 (nth 1 Pt1))

(setq Z1 (nth 2 Pt1))

(setq X2 (nth 0 pt2))

(setq y2 (nth 1 pt2))

(setq Z2 (nth 2 pt2))

(princ (- z1 z2))

(command "_TEXT" pause "20" "0" (rtos (- z1 z2)))

 

;finish cleanly

 

;end of defun

 

But I got an error message where I went wrongerror: ; error: malformed list on input

 

thanks for your help

Link to comment
Share on other sites

  • 4 years later...

The lisp below is what I made to crudely check overlapping vertical alignments (plotted as 3d-polylines).

 

(defun c:Diz (/ pt1 pt2 gss txt_rot )
(setq pt1 (getpoint "\nSelect first point: "))
(setq pt2 (getpoint "\nSelect second point: "))
(setq gss (ssadd))
(setq txt_rot 	(if (> (distance (list (car pt1)(cadr pt1))(list (car pt2)(cadr pt2))) 0.1)
				(+ (angle pt1 pt2)(* PI 1.5))
				0))
(entmake 	(list '(0 . "line")
						(cons 10 pt1) 
						(cons 11 pt2) 
			)
)
(ssadd (entlast) gss) ; add entity to selection set
(entmake (list '(0 . "text")
						(cons 1 (strcat "dZ= "(rtos (abs(*(- (caddr pt1)(caddr pt2))1000)) 2 0)"mm"))
						(cons 10 (polar ent1_pt offset_angle (/ Dist_xy 2))) (cons 11 (polar ent1_pt offset_angle (/ Dist_xy 2))) 
						(cons 10 (list (/(+ (car pt1)(car pt2))2)(/(+ (cadr pt1)(cadr pt2))2)))(cons 11 (list (/(+ (car pt1)(car pt2))2)(/(+ (cadr pt1)(cadr pt2))2)))
						(cons 50 txt_rot)
						'(40 . 1.0)  
						'(72 . 0) 
						'(73 . 2) 
				)
)
(ssadd (entlast) gss) ; add entity to selection set
(command "_.group" "c" "*" "" gss "") ; create group from selection set
(princ)
)

 

Edited by Robert89
Link to comment
Share on other sites

8 hours ago, grifflee said:

Sigi-19 could I be cheeky and ask for a copy of this Lisp routine please? It's just what I'm looking for.

 

Why not use the standard DIST command for this purpose?

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.

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