Looking for end Z LISP

Looking for end Z LISP

Anonymous
Not applicable
1,299 Views
8 Replies
Message 1 of 9

Looking for end Z LISP

Anonymous
Not applicable

I have a road drawn with stations every 50 feet. A line going left and right at every station (so a ton of lines).  If I know the center point elevation at each station, is there a LISP that can calc the end of the line if i input the slope?

 

So start Z = 100.00

     line = 30 feet

     slope = 2%

     LISP would need to automatically change Z value to 99.40

 

is this something that might exist?  i have no idea how to design code so i am not sure if this is even possible

the file attached has the first couple stations done and rest are at all 0 for elevations.  This is because I am typing everything in and thought I would try this forum while i was doing it.

 

 

0 Likes
1,300 Views
8 Replies
Replies (8)
Message 2 of 9

WarrenGeissler
Advisor
Advisor

Hi @Anonymous,

You might want to post your question at the Customization / LISP forum >>HERE<< for a faster answer and wider bandwidth.


Warren Geissler
Drafting Manager Denver Water
_____________________________________________

Please ACCEPT AS SOLUTON if this works
(...and doesn't melt your computer or cause Armageddon)

0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

[You would also need to either  1) ask the question whether that slope is upward or downward, or  B) call for a negative  percentage for a downward slope such as would result in the value described.]

 

That is certainly doable.  In simplest terms just for the calculation:

 

(setq
  elev1 (getreal "\nStarting elevation: ")
  horiz (getdist "\nDistance over which to slope: ")
  slope (getreal "\nPercentage slope (+ upward, - downward, without % sign): ")
); setq
(prompt
  (strcat
    "\nEnding elevation is "
    (rtos (+ elev1 (* horiz slope 0.01)) 2 2)
    "."
  ); strcat
); prompt

 

How that would be applied within a larger context depends on what you want to do with the result [draw the other line endpoint, or change the elevation of an existing Line endpoint, or feed it out to an external text file, or...].

Kent Cooper, AIA
0 Likes
Message 4 of 9

Anonymous
Not applicable

input of +/- for slope i didn't think of but a wonderful idea.  I was hoping it would change the value of the end of the line. not a text block but change the actual Z value in the properties menu.

0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

input of +/- for slope i didn't think of but a wonderful idea.  I was hoping it would change the value of the end of the line. not a text block but change the actual Z value in the properties menu.


In that case, presumably the User will select an existing Line, in which case the length of the Line would not need to be supplied by the User -- the routine can figure that out.  However, is there anything about such a Line from which the routine could determine which end to adjust?  For example, are they always drawn from center-of-roadway to edge?  Or does the center-line end always meet a center-line Polyline or something, but the other end is doesn't intersect anything?  If there's nothing reliable like that, it would need to ask the User to select it near the center-line end, or select it and then designate which end is to remain at its current elevation, or something.

Kent Cooper, AIA
0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor

Are you talking about 3D lines in plan view or in profile?

 

If in plan view you might join the lines into one 3D polyline and download my 3DEDIT.FAS posted here a while back.  You can change vertex elevations individually by typing in the new elevation or by slope from the previous vertex, or you can transition through multiple vertices.

 

If in profile, then the Z value is actually represented by a Y coordinate relative to a datum elevation and must consider the vertical exaggeration, if any.

John F. Uhden

0 Likes
Message 7 of 9

Anonymous
Not applicable

always drawn from the center going out. Start Z would always be correct and End Z would have to be changed. They all start at the centerline and extend to the edge of road. not always the same length but hopefully the length would be automatically detected/known once selected.  

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

So, the centerline is created as a 3D polyline?  And you just want to draw a 3D line to a selected point but at a vertical slope that you enter so that the end Z is calculated for you?

 

Maybe this is what you want...

 

;; LineAtSlope
(defun c:LAS ( / p1 p2 Z ans @2d) (defun @2d (p)(list (car p)(cadr p))) (if (/= (type *slope*) 'REAL)(setq *slope* -2.0)) ; global (while (setq p1 (getpoint "\nFirst point: ")) (setq p2 (getpoint p1 "\nSecond point: ")) (setq ans (getreal (strcat "\nEnter slope in % to 2nd point <" (rtos *slope* 2 2) ">: "))) (if ans (setq *slope* ans)) (setq Z (+ (last p1)(* (distance (@2d p1)(@2d p2)) *slope* 0.01))) (setq p2 (list (car p2)(cadr p2) Z)) (entmake (list '(0 . "LINE")(cons 10 p1)(cons 11 p2))) ) (princ) )

John F. Uhden

0 Likes
Message 9 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

always drawn from the center going out. Start Z would always be correct and End Z would have to be changed. They all start at the centerline and extend to the edge of road. not always the same length but hopefully the length would be automatically detected/known once selected.


For an existing Line that you select, within those particular circumstances [lightly tested]:

 

(defun C:LSA ; = Line Slope Adjust
  (/ lsel lin ldata slope lend)
  (if
    (and
      (setq lsel (entsel "\nSelect Line to adjust its Slope: "))
      (setq lin (car lsel))
      (member '(0 . "LINE") (setq ldata (entget lin)))
    ); and
    (progn ; then
      (setq
        slope (getreal "\nPercentage slope (+ upward, - downward, without % sign): ")
        lend (assoc 11 ldata); [including the 11 -- no need to extract only point coordinates]
      ); setq
      (entmod
        (subst
          (reverse ; turn around for easier replacement of original Z coordinate
            (cons
              (+ (last lend) (* (vla-get-Length (vlax-ename->vla-object lin)) slope 0.01)); new Z
              (cdr (reverse lend)); without original Z coordinate
            ); cons
          ); reverse
          lend
          ldata
        ); subst
      ); entmod
    ); progn
  ); if
  (princ)
); defun

It could easily be adjusted to let you pick a whole batch to process at once, if the slope for all would be the same.

 

Kent Cooper, AIA
0 Likes