Jump to content

Recommended Posts

Posted

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

 

  • dek changed the title to Interpolate with Text Value
Posted

 

 

(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

Posted

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

 

 

 

 

 

 

Posted
 

 

(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

 

 

 

 

  • Like 1
  • 1 month later...
Posted

Can this be modified to make labelling continues on every clicks? i.e. for repeated elevations.

 

Thanks

Posted
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

Posted

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.

Posted
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

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