Author Topic: Elevation interpolation at given point LISP  (Read 7869 times)

0 Members and 1 Guest are viewing this topic.

jackson5

  • Guest
Elevation interpolation at given point LISP
« on: July 28, 2013, 10:34:30 AM »
I am looking for an interpolation lisp that  would work like this (point = inserted block that has Z elevation):
- set the accuracy of the interpolation (for example 1, 0.1 , 0.01)
- click on the first point that that has Z coordinate (if there is no block/survey point founded enter the elevation manually)
- click on the second point that has Z coordinate (if there is no block/survey point founded enter the elevation manually)
- click on any place between 1st and 2nd point
- the lisp puts an autocad-point which has interpolated elev. at given place and you get the calculated elev. on the prompt
  history window
Can someone help me with this?

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Elevation interpolation at given point LISP
« Reply #1 on: July 28, 2013, 11:39:33 AM »
I am looking for an interpolation lisp that  would work like this (point = inserted block that has Z elevation):
- set the accuracy of the interpolation (for example 1, 0.1 , 0.01)
- click on the first point that that has Z coordinate (if there is no block/survey point founded enter the elevation manually)
- click on the second point that has Z coordinate (if there is no block/survey point founded enter the elevation manually)
- click on any place between 1st and 2nd point
- the lisp puts an autocad-point which has interpolated elev. at given place and you get the calculated elev. on the prompt
  history window
Can someone help me with this?

What you are looking for is a combination of several lisp functions, it is possible but not a quick answer.  The interpolation part is simple enough, but then you are looking to insert a block with attributes for the elevation.

jackson5

  • Guest
Re: Elevation interpolation at given point LISP
« Reply #2 on: July 28, 2013, 12:03:16 PM »
Thanks for your reply. The final part would be inserting a simple autocad-point with interpolated elevation, not a block...

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Elevation interpolation at given point LISP
« Reply #3 on: July 28, 2013, 01:55:54 PM »
Thanks for your reply. The final part would be inserting a simple autocad-point with interpolated elevation, not a block...

Here is a simple lisp to do just that;
Code - Auto/Visual Lisp: [Select]
  1. (defun C:BFcp ( / pnt1 pnt2 pt1 lineent)
  2.    (defun DRline ( )
  3.         (ENTMAKE
  4.              (LIST '(0 . "LINE")
  5.                         '(100 . "AcDbEntity")                    
  6.                         '(67 . 0)
  7.                         '(410 . "Model" )
  8.                          (CONS 8  "0")                  ; Layer
  9.                         '(100 . "AcDbLine")
  10.                          (CONS 10  pnt1)                ; Vertices
  11.                          (CONS 11  pnt2)                       
  12.                         )
  13.              )
  14.     );defun
  15.  (defun DRpoint ( )
  16.         (ENTMAKE
  17.              (LIST '(0 . "POINT")
  18.                         '(100 . "AcDbEntity")                    
  19.                         '(67 . 0)
  20.                         '(410 . "Model" )
  21.                          (CONS 8  "0")          ; Layer
  22.                         '(100 . "AcDbPoint")
  23.                          (CONS 10  pt1)         ; Vertices
  24.                         )
  25.              )
  26.     );defun (DRpoint)
  27.   (if (/= (getvar 'pdmode)1)
  28.     (progn
  29.       (setvar 'osmode 8)
  30.       (setq pnt1 (getpoint        "\n Screen Select An Existing 3d-Point; "))
  31.       (while (= (caddr pnt1) 0.0)
  32.       (setq pnt1 (getpoint    "\n Pnt Selected has <0.0'> Elevation\n Re-Select or Enter 3D Coordinates <x,y,z> !"))
  33.         );while
  34.       (setq pnt2 (getpoint pnt1   "\n Screen Select Second Existing 3d-Point; "))
  35.       (while (= (caddr pnt2) 0.0)
  36.         (setq pnt2 (getpoint  pnt1  "\n Pnt Selected has <0.0'> Elevation\n Re-Select or Enter 3D Coordinates <x,y,z> !"))
  37.         );while
  38.       (Drline)
  39.       (setvar 'osmode 512)
  40.       (setq lineent (entlast)
  41.                pt1 (getpoint "\n Screen Select Location of New Point Along the Work Line; ")
  42.                )
  43.       (entdel lineent)
  44.       (DRpoint)
  45.       (princ)
  46.       (princ (strcat "\n Point Elevation = " (rtos (caddr pt1) 2 2) "'"))
  47.       (princ)
  48.       )
  49.     (alert "PDmode = 1, no point will be visable, Please RESET & run Again !")
  50.     )
  51.   );defun (C:BFcp)
  52.  
  53. (princ "/nType < BFcp > to run !")

I'm cheating by using object snap modes to do the interpolating for me.

Have fun....

Bruce
« Last Edit: July 28, 2013, 04:43:35 PM by snownut2 »

jackson5

  • Guest
Re: Elevation interpolation at given point LISP
« Reply #4 on: July 28, 2013, 04:56:01 PM »
I checked your code, quite neat.

Is that very complicated to modify the code to get the elevation from any object selected
(point, block, 3d polyline vertex) that is elevated? Right now it works with ACAD points only.

I wish also to type the elevation manually in case no object that has Z elevation is selected.
I mean, when I get "Screen Select An Existing 3d-Point;" and I click on the area that no 3dpoints
are present, the program would take the X and Y coordinates from the place I would click and I would
type the  Z elevation (the missing coordinate) manually.
And now, as far as I can understand the LISP code, only if I pick the 3dpoint with 0,0 elevation I need to
put all 3 coordinates.

What's that LISP for? It's simple. Usually you get maps from the surveyor with 3dpoints. Normally you prepare
the 3d-model of the surface needed, but on the early stage, for a quick measurements you need very often to
use some points from raster image, which doesn't have any data that can be used (it's flat image). So you can
click on the "points" of the raster image to interpolate it manually ("measure" command). It's not very comfortable way...



snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Elevation interpolation at given point LISP
« Reply #5 on: July 28, 2013, 05:02:15 PM »
I checked your code, quite neat.

Is that very complicated to modify the code to get the elevation from any object selected
(point, block, 3d polyline vertex) that is elevated? Right now it works with ACAD points only.

I wish also to type the elevation manually in case no object that has Z elevation is selected.
I mean, when I get "Screen Select An Existing 3d-Point;" and I click on the area that no 3dpoints
are present, the program would take the X and Y coordinates from the place I would click and I would
type the  Z elevation (the missing coordinate) manually.
And now, as far as I can understand the LISP code, only if I pick the 3dpoint with 0,0 elevation I need to
put all 3 coordinates.

What's that LISP for? It's simple. Usually you get maps from the surveyor with 3dpoints. Normally you prepare
the 3d-model of the surface needed, but on the early stage, for a quick measurements you need very often to
use some points from raster image, which doesn't have any data that can be used (it's flat image). So you can
click on the "points" of the raster image to interpolate it manually ("measure" command). It's not very comfortable way...

To get it to work for other types of objects just change this line;
Code - Auto/Visual Lisp: [Select]
  1. (setvar 'osmode 8)
To an acceptable snap mode.

If you follow the code, it should not be UN-reasonably difficult to accept the x & y variables of the selected point and add the z coordinate manually.

Bruce