dek Posted October 29, 2020 Share Posted October 29, 2020 Greetings, I am new to getting cad points and elevations and mostly my work is civil, I have download some .lsp from some site regarding interpolation between two elevations the code is good for me,but I want to ask if this can have the output value to have text currently the interpolated value only shows at the command just want to have the value as text here is the code ;Calculates elevation between two known elevation points. (defun C:INTERPOLATE (); / x x1 x2 x3 x4 x5) (setq x (getpoint "\nFirst point: ") x1 (getreal "\nElevation at first point: ") x2 (getpoint "\nSecond point: ") x3 (getreal "\nElevation at second point: ") x4 (getpoint "\nPoint to be calculated: ")) (if (> x1 x3) (setq x5 (- x1 (* (/ (- x1 x3) (distance x x2)) (distance x x4)))) (setq x5 (- x3 (* (/ (- x3 x1) (distance x x2)) (distance x2 x4)))) );*if (prompt (strcat "\nElevation is " (rtos x5) ": ")) (princ) );*defun thank you Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted October 29, 2020 Share Posted October 29, 2020 (defun C:INTERPOLATE (); / x x1 x2 x3 x4 x5) (setq x (getpoint "\nFirst point: ") x1 (getreal "\nElevation at first point: ") x2 (getpoint "\nSecond point: ") x3 (getreal "\nElevation at second point: ") x4 (getpoint "\nPoint to be calculated: ")) (if (> x1 x3) (setq x5 (- x1 (* (/ (- x1 x3) (distance x x2)) (distance x x4)))) (setq x5 (- x3 (* (/ (- x3 x1) (distance x x2)) (distance x2 x4)))) );*if (setq xyz (getpoint "\mtext point: ")) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") (assoc 8 (entget sn)) (cons 10 xyz) (cons 1 (strcat "\nElevation is " (rtos x5) ": ") ) (cons 7 (getvar 'textstyle)) (cons 40 (if (eq (cdr (assoc 40 (setq sty (entget (tblobjname "style" (getvar 'textstyle))) ) ) ) 0. ) (cdr (assoc 42 sty)) (cdr (assoc 40 sty)) ) ) '(71 . 5) ) ) (princ) );*defun Quote Link to comment Share on other sites More sharing options...
dek Posted October 30, 2020 Author Share Posted October 30, 2020 hi thanks for the reply but im getting the error code on Command: INTERPOLATE First point: Elevation at first point: -2.606 Second point: Elevation at second point: -2.182 Point to be calculated: _cen of mtext point: 1 ; error: bad argument type: lentityp nil Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 30, 2020 Share Posted October 30, 2020 (assoc 8 (entget sn)) there is no entity sn 1 Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted October 30, 2020 Share Posted October 30, 2020 (defun C:INTERPOLATE (); / x x1 x2 x3 x4 x5) (setq x (getpoint "\nFirst point: ") x1 (getreal "\nElevation at first point: ") x2 (getpoint "\nSecond point: ") x3 (getreal "\nElevation at second point: ") x4 (getpoint "\nPoint to be calculated: ")) (if (> x1 x3) (setq x5 (- x1 (* (/ (- x1 x3) (distance x x2)) (distance x x4)))) (setq x5 (- x3 (* (/ (- x3 x1) (distance x x2)) (distance x2 x4)))) );*if (setq xyz (getpoint "\mtext point: ")) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(8 . "level") (cons 10 xyz) (cons 1 (strcat "\nElevation is " (rtos x5) ": ") ) (cons 7 (getvar 'textstyle)) (cons 40 (if (eq (cdr (assoc 40 (setq sty (entget (tblobjname "style" (getvar 'textstyle))) ) ) ) 0. ) (cdr (assoc 42 sty)) (cdr (assoc 40 sty)) ) ) '(71 . 5) ) ) (princ) );*defun 1 Quote Link to comment Share on other sites More sharing options...
anwar186 Posted December 10, 2020 Share Posted December 10, 2020 Can this be modified to make labelling continues on every clicks? i.e. for repeated elevations. Thanks Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted December 10, 2020 Share Posted December 10, 2020 2 hours ago, anwar186 said: Can this be modified to make labelling continues on every clicks? i.e. for repeated elevations. Thanks (defun C:TESTINTERPOLATE (); / x x1 x2 x3 x4 x5) (WHILE (PROGN (setq x (getpoint "\nFirst point: ") x1 (getreal "\nElevation at first point: ") x2 (getpoint "\nSecond point: ") x3 (getreal "\nElevation at second point: ") x4 (getpoint "\nPoint to be calculated: ")) (if (> x1 x3) (setq x5 (- x1 (* (/ (- x1 x3) (distance x x2)) (distance x x4)))) (setq x5 (- x3 (* (/ (- x3 x1) (distance x x2)) (distance x2 x4)))) );*if (setq xyz (getpoint "\mtext point: ")) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(8 . "level") (cons 10 xyz) (cons 1 (strcat "\nElevation is " (rtos x5) ": ") ) (cons 7 (getvar 'textstyle)) (cons 40 (if (eq (cdr (assoc 40 (setq sty (entget (tblobjname "style" (getvar 'textstyle))) ) ) ) 0. ) (cdr (assoc 42 sty)) (cdr (assoc 40 sty)) ) ) '(71 . 5) ) ) );;PROGN );;WHILE (princ) );*defun Quote Link to comment Share on other sites More sharing options...
anwar186 Posted December 12, 2020 Share Posted December 12, 2020 I tried but I am not getting the repeat prompt "Point to be calculated" so that i can click more points on the same line. Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted December 12, 2020 Share Posted December 12, 2020 50 minutes ago, anwar186 said: I tried but I am not getting the repeat prompt "Point to be calculated" so that i can click more points on the same line. (defun C:TESTINTERPOLATE ( / STY X X1 X2 X3 X4 X5 XYZ); / x x1 x2 x3 x4 x5) (setq x (getpoint "\nFirst point: ") x1 (getreal "\nElevation at first point: ") x2 (getpoint "\nSecond point: ") x3 (getreal "\nElevation at second point: ") ) (WHILE (setq x4 (getpoint "\nPoint to be calculated: ")) (PROGN (if (> x1 x3) (setq x5 (- x1 (* (/ (- x1 x3) (distance x x2)) (distance x x4)))) (setq x5 (- x3 (* (/ (- x3 x1) (distance x x2)) (distance x2 x4)))) );*if (setq xyz (getpoint "\mtext point: ")) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(8 . "level") (cons 10 xyz) (cons 1 (strcat "\nElevation is " (rtos x5) ": ") ) (cons 7 (getvar 'textstyle)) (cons 40 (if (eq (cdr (assoc 40 (setq sty (entget (tblobjname "style" (getvar 'textstyle))) ) ) ) 0. ) (cdr (assoc 42 sty)) (cdr (assoc 40 sty)) ) ) '(71 . 5) ) ) );;PROGN );;WHILE (princ) );*defun Quote Link to comment Share on other sites More sharing options...
anwar186 Posted December 13, 2020 Share Posted December 13, 2020 Thanks Hosneyalaa now its working perfect. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.