+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 28
  1. #1
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Oct 2008
    Posts
    45

    Default Interpolation Lisp Needed

    Registered forum members do not see this ad.

    AutoCAD 2007
    Basically I am looking for some help in finding an interpolation lisp that will work in the order below. Not sure if anyone has something like this already that they could share. I have provided a couple interpolation lisps I have found, maybe they could help someone.

    I am looking for an interpolation lisp that has steps in this order...
    -click on first point
    -enter elevation of the first point
    -click on second point
    -enter elevation of the second point
    -have the lisp place a "x" node point or a letter "x" in the current text style assigned (with a middle center insertion point at its center) at all the whole numbers between the two points

    For example if the first point = elevation 120.50 and the second point = elevation 123.00. The lisp will interpolate and place an "X" between the two points clicked, at elevation 121.00 and at 122.00

    Thank You
    Attached Files

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    see if this works for you
    Code:
    (defun c:test (/ pt1 el1 pnt1 pt1 el2 pnt2 len el1a slp d1)
      (vl-load-com)
      (setvar "osmode" 0)
      (setvar "pdmode" 3)
      (setq pt1 (getpoint "\nPick point 1: ")
        el1 (getreal "\nEnter elevation 1: ")
        pnt1 (list (car pt1) (cadr pt1) el1)
        pt2 (getpoint pt1 "\nPick point 2: ")
        el2 (getreal "\nEnter elevation 2: ")
        pnt2 (list (car pt2) (cadr pt2) el2)
        len (distance pnt1 pnt2)
            el1a (1+(fix el1))
            slp (/  (- el2 el1)(distance pnt1 pnt2))
        d1 (/ (- el1a el1) slp)
        )
      (setq obj (vlax-ename->vla-object
         (entmakex
           (list
             (cons 0 "LINE")
             (cons 10 pnt1)
             (cons 11 pnt2)
             )
           )
        )
        )
      (while (< d1 len)
             (entmakex
           (list
             (cons 0 "POINT")
             (cons 10 (vlax-curve-getPointAtDist Obj d1))
             )
           )
        (setq d1 (+ d1 (/ 1 slp)))
        )
      (princ)
      )

  3. #3
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Oct 2008
    Posts
    45

    Default Thank You

    WOW!, the lisp above is amazing. You even wrote the lisp to add the "z" elevation of the node points. I really can't believe how good this works, I didn't really think this one could be done so well.

    Not sure how easily it can be done, but I was wondering, now that I see this lisp can be created, if anyone would be able to tweak it a little.

    1. it wipes out the osnap settings when the lisp is activated, can it be edited to keep the existing osnap settings?

    2. would it be possible to instead of entering the beginning two known spot shot elevations manually, can it detect the "z" elevations that are assigned to the node points, automatically?

    Thank you so much for your help, you went above and beyond my expectations. I really can't believe how you were able to get this to work so well. Even without the above fixes, I am extremely satisfied with the results. I really appreciate it.

  4. #4
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    If the 2 points have equal elevations, you'll get a 'divide by zero' error... I don't have the time now to include error control
    Code:
    (defun c:test (/ pt1 el1 pnt1 pt1 el2 pnt2 len el1a slp d1)
      (vl-load-com)
      (setq oldsnap (getvar "osmode"));tweak
      (setvar "osmode" 0)
      (setvar "pdmode" 3)
      (setq pt1 (getpoint "\nPick point 1: ")
        el1  (caddr pt1);(getreal "\nEnter elevation 1: ")tweak
        pnt1 (list (car pt1) (cadr pt1) el1)
        pt2 (getpoint pt1 "\nPick point 2: ")
        el2 (caddr pt2);(getreal "\nEnter elevation 2: ")tweak
        pnt2 (list (car pt2) (cadr pt2) el2)
        len (distance pnt1 pnt2)
            el1a (1+(fix el1))
            slp (/  (- el2 el1)(distance pnt1 pnt2))
        d1 (/ (- el1a el1) slp)
        )
      (setq obj (vlax-ename->vla-object
         (entmakex
           (list
             (cons 0 "LINE")
             (cons 10 pnt1)
             (cons 11 pnt2)
             )
           )
        )
        )
      (while (< d1 len)
             (entmakex
           (list
             (cons 0 "POINT")
             (cons 10 (vlax-curve-getPointAtDist Obj d1))
             )
           )
        (setq d1 (+ d1 (/ 1 slp)))
        )
      (setvar "osmode" oldsnap);tweak
      (princ)
      )
    I hope you're 'dissecting' the code so you can learn from it... it really isn't that complicated
    Last edited by lpseifert; 8th Feb 2010 at 06:09 pm.

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    How about this:

    Code:
    (defun c:test (/ p1 p2 i e n inc)
      (setvar "PDMODE" 3)
    
      (cond ((and (setq p1 (getpoint "\nPick Point 1: "))
                  (setq p2 (getpoint "\nPick Point 2: " p1)))
    
             (setq i 0 e (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))
                   
                   inc (/ (setq n (fix (abs (- (caddr p2) (caddr p1)))))
                          (distance p1 p2)))
    
             (while (< (setq i (1+ i)) n)
               (entmake (list (cons 0 "POINT")
                              (cons 10 (vlax-curve-getPointatDist e (/ i inc))))))))
      (princ))
    Last edited by Lee Mac; 11th Feb 2010 at 11:43 pm.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Full Member
    Using
    AutoCAD 2008
    Join Date
    Oct 2008
    Posts
    45

    Default Thanks Guys

    lpseifert

    The lisp you supplied works great, it takes the "z" elevation assigned to the point. This also helps me learn, now that I can see what it takes to do this manually in the first lisp you wrote, and automatically in this one.
    The new lisp you wrote did have a little problem with the osnap settings but I was able to fix it, by deleting the "setvar osmode 0" line.
    Now the lisp works perfect.

    Thank you so much for all your help, the lisp works great, I really appreciate it. In response to your comment, I am trying to learn about what it takes to create lisps. All the lisps I have been asking have a dual purpose, one is to obviously get more efficient drafting tools, but also to learn all the different codes based on the different scenarios I ask for.

    Lee Mac

    The lisp you supplied, works like lpseifert lisp above, but it places the "x" points with weird z elevations. Not a problem, everything works now. Thank you as well for your response.


    One more thing, on another forum I was not aware that you could rate the help given. Is there anything I can rate users? I have been trying to help others but by time I read questions, they are already answered by others.

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Quote Originally Posted by johnshar123xx View Post
    Lee Mac

    The lisp you supplied, works like lpseifert lisp above, but it places the "x" points with weird z elevations.
    It seems to work OK for me, placing points at every integer elevation between selected points. I really just wanted to make lpseifert's Lisp more concise
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Jun 2010
    Posts
    1

    Default interpolation

    is there any lisp program that interpolates the two points then with that result point and a slope, calculates the level of third point perpendicular to the line joining the first two points? It is for road kerb line level calculation. given the road center line FRLs. can anyone help me?

  9. #9
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Jun 2010
    Posts
    8

    Default

    This lisp is amazing, but can anyone help me. I need to interpolate with 0.25 height difference. For example 21.25 21.50 21.75 22.00 .

    I have been looking at this code for an hour now and I don't get it.

    I could really use your help because I need to create a topographic map and I have to interpolate over 300 points.

  10. #10
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Registered forum members do not see this ad.

    Are you referring to my code Ogre?
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. LISP Needed
    By good_m in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 21st May 2009, 01:40 pm
  2. lisp needed
    By CadTechJGC184 in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 18th May 2009, 09:23 pm
  3. Interpolation in 3D
    By ramis in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 15th Aug 2007, 01:03 am
  4. S.O.S. - LISP &/or VBA Assistance Needed
    By Broman in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 24th Nov 2006, 09:35 pm
  5. height interpolation error
    By salane in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 14th Jun 2006, 02:15 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts