Author Topic: Tough Questions - Override "Z" Elevation Lisp  (Read 4029 times)

0 Members and 1 Guest are viewing this topic.

johnshar123xx

  • Guest
Tough Questions - Override "Z" Elevation Lisp
« on: November 30, 2009, 02:24:19 PM »
Tough Questions - Override "Z" Elevation Lisp


AutoCAD 2007
I have a quite a few tough questions/requests and I am currently looking for some lisps to solve them.  I have been doing some searching online to find the lisps I need, and although I have been able to find some stuff, I still have some things that I can't seem to find exactly what I am looking for.  I would like to take the opportunity ahead of time to thank every who views my questions and for any help that is given.

Wondering if anyone knows of an override that will allow you to temporarily turn off "Z" elevations set to lines in your drawing.
For example, lets say you have contour lines in a site plan that have "Z" elevations set to them.  If you try to get a 2d distance from line to line, the distance command factors in the "Z" elevation giving you an inaccurate distance reading.
Another example, when you want to draw a 2D line and you snap your line to a contour line that has a "Z" elevation set to it, the line in essence snaps to the "Z" elevation of the line making it 3D as opposed to 2D.
Does anyone know of a variable or a lisp that will allow you to temporarily override the "Z" elevations in a drawing?

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #1 on: November 30, 2009, 02:29:29 PM »
Well.. FLATTEN.. but thats the point of no return...  :wink:

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #2 on: November 30, 2009, 02:34:24 PM »
Just thinking out loud....

You can write a LSP that allows the user to select two points (I.E. your different contour lines) and then from those two points extract their X & Y values.  Then create a list for the first point using the X & Y value extracted in addition to adding 0 for the Z elevation.  Do the same for point 2, then draw a line from point 1 to point 2.

I haven't done LSP in quite some time now, but I've got some code kicking around (unless someone beats me to it).
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Maverick®

  • Seagull
  • Posts: 14778
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #3 on: November 30, 2009, 02:37:51 PM »
Wow.  "Tough questions" here, on Cadtutor, and on Augi.  That oughta get 'er done.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #4 on: November 30, 2009, 02:38:57 PM »
I think it's called "covering your bases".   :wink:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #5 on: November 30, 2009, 02:47:33 PM »
Just thinking out loud....

You can write a LSP that allows the user to select two points (I.E. your different contour lines) and then from those two points extract their X & Y values.  Then create a list for the first point using the X & Y value extracted in addition to adding 0 for the Z elevation.  Do the same for point 2, then draw a line from point 1 to point 2.

I haven't done LSP in quite some time now, but I've got some code kicking around (unless someone beats me to it).

Like this?

Code: [Select]
(defun c:2DDist (/ 2dp x1 lst x2 d)

  (defun 2dp (p) (list (car p) (cadr p) 0.))
 
  (if (setq x1 (getpoint "\nSelect First Point: "))
    (progn
      (setq lst (cons (2dp x1) lst) d 0.)
      (while (setq x2 (getpoint (car lst) "\nSelect Next Point: "))
        (setq lst (cons (2dp x2) lst) d (+ d (distance (car lst) (cadr lst))))) 
      (princ (strcat "\n<< 2D Distance: " (rtos d 2 3) " >>"))))
 
  (princ))

Chris

  • Swamp Rat
  • Posts: 548
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #6 on: November 30, 2009, 03:20:37 PM »
I think it's called "covering your bases".   :wink:
yeah, but the questions here are different than the ones at AUGI
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #7 on: November 30, 2009, 03:24:47 PM »
I think it's called "covering your bases".   :wink:
yeah, but the questions here are different than the ones at AUGI

Still.. they are identical to those at CADTutor...  :wink:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #8 on: November 30, 2009, 03:34:04 PM »
Another way. 8-)
Code: [Select]
(defun c:2DDist (/ x1 x2 d)
  (if (setq x1 (getpoint "\nSelect First Point: "))
    (progn
      (while (setq x2 (getpoint x1 "\nSelect Next Point: "))
        (setq d   (sqrt (+ (expt (- (car x2) (car x1))2) (expt (- (cadr x2) (cadr x1))2) )))
        (princ (strcat "\n<< 2D Distance: " (rtos d 2 3) " >>"))
      )
    )
  )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #9 on: November 30, 2009, 04:04:31 PM »
Code: [Select]
(initget 64)
(getdist)

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #10 on: November 30, 2009, 04:19:45 PM »

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #11 on: November 30, 2009, 04:20:46 PM »
Couldn't resist:

Code: [Select]
(defun c:2DDist (/ 2dp x1 lst x2 d gr)

  (defun 2dp (p) (list (car p) (cadr p) 0.))
 
  (if (setq x1 (getpoint "\nSelect First Point: "))
    (progn
      (setq lst (cons (2dp x1) lst) d 0. gr lst)
      (while (setq x2 (getpoint (car lst) "\nSelect Next Point: "))
        (setq lst (cons (2dp x2) lst) d (+ d (distance (car lst) (cadr lst)))
              gr  (append gr (if (< 1 (length gr)) (list (last gr) (car lst)) (list (car lst)))))
        (and (< 1 (length gr)) (grvecs (cons -3 gr))))
      (princ (strcat "\n<< 2D Distance: " (rtos d 2 3) " >>"))))
 
  (princ))


Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #12 on: November 30, 2009, 04:24:29 PM »
Perhaps better programming:

Code: [Select]
(defun c:2DDist (/ 2dp x1 lst x2 d)

  (defun 2dp (p) (list (car p) (cadr p) 0.))
 
  (if (setq x1 (getpoint "\nSelect First Point: "))
    (progn
      (setq lst (cons (2dp x1) lst) d 0.)
      (while (setq x2 (getpoint (car lst) "\nSelect Next Point: "))
        (setq lst (cons (2dp x2) lst) d (+ d (distance (car lst) (cadr lst))))
        (apply 'grvecs
           (list
             (cons '-3
               (apply 'append
                 (mapcar 'list (reverse (cdr lst)) (cdr (reverse lst))))))))
      (princ (strcat "\n<< 2D Distance: " (rtos d 2 3) " >>"))))
 
  (princ))

CHulse

  • Swamp Rat
  • Posts: 504
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #13 on: November 30, 2009, 07:14:45 PM »
What about OSNAPZ?
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #14 on: December 01, 2009, 08:07:40 AM »
What about OSNAPZ?
Why do you have to make it so easy?   :-D


I forgot about that one!  Is that just for the verticals or does it work in Vanilla, too?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #15 on: December 01, 2009, 09:12:21 AM »
Well, there are others posting solutions so I figured what the heck ... I'll add my 2p

Code: [Select]
(defun dist2D (pt1 pt2)
  (apply 'distance
    (mapcar
      '(lambda (x)
        (if (= (length x) 3)
         (reverse (cdr (reverse x)))
         x
        )
       )
       (list pt1 pt2)
    )
  )
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

johnshar123xx

  • Guest
Re: Tough Questions - Override "Z" Elevation Lisp
« Reply #17 on: December 01, 2009, 04:43:45 PM »
Wow, I thank you all for taking the time to help me out with this and any of my other questions, it is greatly appreciated, it appears as if OSNAPZ does the trick.  I realize that some of my requests are rather complex, I wish I had the ability to write lisps myself, I am looking into it, but the lisps users are supplying to answer my questions help me to get an idea as to what it takes to create them.  I still have quite a few questions, so thanks again ahead of time to those willing to lend their time and knowledge to help.