+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Slope arrow

  1. #1
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default Slope arrow

    Registered forum members do not see this ad.

    We used to have a routine in VB for indicating the slope of a line in % terms. The guy who wrote it has left the office and I know even less about VB compared to lisp. I was wondering if someone could write a lisp to produce the arrow ad text as shown in the attached file based on the current textstyle and dimstyle?

    Thanks.
    Attached Images

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

    Default

    Aw give it a try... I'm sure someone here will help if you get stuck.

    This might help you get started
    Code:
    ;;;returns slope of line/polyline in profile LPS with help from ronjomp 2008
    (defun c:sl ()
      (vl-load-com)
      (setq ent (entsel))
      (if (= (cdr (assoc 0 (entget (car ent)))) "LINE")
        (progn
          (setq lst     (entget (car ent))
            pt1     (cdr (assoc 10 lst))
            pt2     (cdr (assoc 11 lst))
            x1     (car pt1)
            y1     (cadr pt1)
            x2     (car pt2)
            y2     (cadr pt2)
            dy     (- y2 y1)
            dx     (- x2 x1)
            slp     (* 100 (/ dy dx))
            slp2 (/ dx dy)
            txtx (rtos (abs dx) 2 2)
            txty (rtos dy 2 2)
            txts (rtos slp 2 2)
            txts2 (rtos slp2 2 2)
          )                    ;setq
        )                    ;progn
        (progn
          (setq pt    (osnap (cadr ent) "nea")
            ent    (car ent)
          )                    ;setq
          (defun getadjacentplinevertices (ent pt / i p1 p2)
        (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
          (progn
            (setq i  (fix (vlax-curve-getParamAtPoint
                    ent
                    (vlax-curve-getClosestPointTo ent pt)
                  )
                 )
              p1 (vlax-curve-getPointAtParam ent i)
              p2 (vlax-curve-getPointAtParam ent (+ 1 i))
            )
            (setq ls1 (list p1 p2))
          )                ;progn
        )                ;if
          )                    ;defun
          (getadjacentplinevertices ent pt)
          (setq p1x     (car (car ls1))
            p1y     (cadr (car ls1))
            p2x     (car (cadr ls1))
            p2y     (cadr (cadr ls1))
            dx     (- p2x p1x)
            dy     (- p2y p1y)
            slp     (* 100 (/ dy dx))
            slp2 (/ dx dy)
            txtx (rtos (abs dx) 2 2)
            txty (rtos dy 2 2)
            txts (rtos slp 2 2)
            txts2 (rtos slp2 2 2)
          )                    ;setq
        )                    ;progn
      )                    ;if
      (prompt (strcat "\nHorizontal distance = " txtx "'"
                     "\nRelief = " txty "'"
                     "\nSlope is " txts "%..." txts2 ":1")
    )
        
    (princ)
    )
    Last edited by lpseifert; 15th Jan 2010 at 01:27 pm.

  3. #3
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default

    Thanks, this has the basics of what i need but can it be put in the format as per my image at the start of the post??

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

    Default

    Yes it can... did you give an attempt to do it?

  5. #5
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default

    to be honest i wouldn't know where to begin.....

  6. #6
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default

    Can anyone help with this???

  7. #7
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,588

    Default

    Quote Originally Posted by woodman78 View Post
    Can anyone help with this???
    Try this one
    Text height will the same as for the current dimension style text height

    Code:
    ;; draw arrow w/slop
    (defun c:das (/ ang coords dx dy elist en ent ldlist ldpt
             mpt p1 p2 pline seg_num slp sorted txpt
             txtang txth txts unsorted)
    (while
      (setq ent
      (entsel
        "\nSelect desired segment of the polyline (or pres Enter to Exit): ")
     )
       (if (eq "LWPOLYLINE"
        (cdr (assoc 0 (setq elist (entget (setq en (car ent)))))))
         (progn
           (setq coords (vl-remove-if
            (function not)
            (mapcar (function (lambda (x)
           (if (= 10 (car x))
             (cdr x))))
             elist)))
           (setq
      seg_num (1+ (fix (vlax-curve-getparamatpoint
           en
           (vlax-curve-getclosestpointto en (cadr ent))))))
           (setq p2       (nth (1- seg_num) coords)
          p1       (nth seg_num coords)
          unsorted (list p2 p1)
          )
           (setq sorted (vl-sort unsorted
            (function (lambda (a b) (< (car a) (car b)))))
          p1     (car sorted)
          p2     (cadr sorted)
          mpt    (mapcar (function (lambda (a b) (/ (+ a b) 2)))
           p2
           p1)
          )
           (setq dx   (- (car p2) (car p1))
          dy   (- (cadr p2) (cadr p1))
          slp  (* 100 (/ dy dx))
          txts (rtos (abs slp) 2 2)
          )
           (setq ang  (angle p1 p2)
          txth (getvar "DIMTXT");<-- you can change the text height here
          )
           (setq ldpt   (polar mpt (+ ang (/ pi 2)) txth)
          txpt   (polar mpt (+ ang (/ pi 2)) (* txth 2))
          txtang (* ang (/ 180.0 pi))
          )
           (command "_.MTEXT"
      txpt
      "_H"
      txth
      "_J"
      "_BC"
      "_R"
      txtang
      "_non"
      txpt
      (strcat (rtos slp 2 2) "%")
      "")
           (setq ldlist
          (list
            (list (* txth 2) 0.)
            (list (* -2 txth) 0.)
            (list (* -2 txth) (/ txth 3))
            (list (* -5 txth) 0.)
            (list (* -2 txth) (/ txth -3))
            (list (* -2 txth) 0.)
            )
          ldlist (mapcar (function (lambda (x) (mapcar '+ ldpt x))) ldlist)
          )
           (entmake
      (append
        (list
          '(0 . "LWPOLYLINE")
          '(100 . "AcDbEntity")
          '(8 . "0")
          '(100 . "AcDbPolyline")
          (cons 90 (length ldlist))
          (cons 70 0)
          (cons 43 0.0)
          )
        (mapcar '(lambda (x) (cons 10 x)) ldlist)
        )
      )
           (setq pline (entlast))
           (command "_.ROTATE"
      pline
      ""
      "_non"
      ldpt
      (if (minusp slp)
        (+ txtang 180)
        txtang))
           )
         )
       )
      (princ)
      )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  8. #8
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default

    That's exactly what i was looking for Fixo. Thanks

  9. #9
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,588

    Default

    Quote Originally Posted by woodman78 View Post
    That's exactly what i was looking for Fixo. Thanks
    Check slope calculation coz I'm not a big math

    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  10. #10
    Super Member
    Computer Details
    woodman78's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell GX280
    Discipline
    Transport
    woodman78's Discipline Details
    Occupation
    Road Design Engineer
    Discipline
    Transport
    Details
    I work in a local authority design office with a staff of 13. We carry out road schemes ranging from overlays up to 2 km long new schemes.
    Using
    Civil 3D 2011
    Join Date
    Jul 2009
    Location
    Ireland
    Posts
    675

    Default

    Registered forum members do not see this ad.

    I'll check it Fixo. I was wondering if you could make a version that would display the slope based on Z values of coords and put a small "v" after the %. I am wokring using 3d polylines a lot at the moment and that would be great.

    Thanks

Similar Threads

  1. how do you shade 20% slope
    By paulg in forum AutoCAD General
    Replies: 5
    Last Post: 21st Jan 2010, 09:00 pm
  2. 3D Slope Dimension
    By petrading in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 3rd Nov 2009, 05:21 pm
  3. Slope arrow
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 21st Oct 2009, 04:20 pm
  4. Slope Calc
    By Martini in forum Civil 3D & LDD
    Replies: 2
    Last Post: 8th Apr 2009, 08:00 pm
  5. Slope of a line
    By smorales02 in forum AutoCAD General
    Replies: 19
    Last Post: 13th Aug 2008, 03:50 pm

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