+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 44
  1. #1
    Senior Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    267

    Drawing draw chainage on polyline

    Registered forum members do not see this ad.

    Hello to all
    can any one help to draw chainage for equal distance on a polyline as in attached jpg
    Attached Images

  2. #2
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    I believe this has been discussed a few times and routine(s) have been posted. Try searching for "stationing" which is the U.S. equivalent to "chainage".

  3. #3
    Full Member jason tay's Avatar
    Using
    AutoCAD 2008
    Join Date
    Jan 2008
    Location
    Malaysia
    Posts
    82

    Default

    Hi, you can use block, create a line in block then use measure command,type block, block name and create the chainage line base on the measurement you want.

    hope can help :_)

  4. #4
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

  5. #5
    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,684

    Default

    I'm crazy busy and can't to rewrite it
    to your exact needs but hope this
    will get you started

    Code:
    (defun div-error (msg)
      (if
        (vl-position
          msg
          '("console break"
        "Function cancelled"
        "quit / exit abort"
           )
        )
         (princ "Error!")
         (princ msg)
      )
      (while (> (getvar "cmdactive") 0) (command))
    ;;;  (command "._undo" "_end")
    ;;;  (command "._u")
      (setq *error* olderror)
      (princ)
    )
     
    (defun divplus (len segm / num lst)
      (setq num (fix (/ len segm)))
      (setq cnt 0)
      (while (<= cnt num)
        (setq tmp (* cnt segm))
        (setq lst (append lst (list tmp)))
        (setq cnt (1+ cnt))
      )
      (setq delta (- len (last lst)))
      (if (not (zerop delta))
        (setq lst (append lst (list (+ (last lst) delta))))
        lst
      )
    )
     
    (defun divminus    (len segm / lst)
      (while (>= len 0.)
        (setq lst (append lst (list len)))
        (setq len (- len segm))
      )
      (if (not (zerop (last lst)))
        (setq lst (append lst (list 0.0)))
      )
      lst
    )
     
    (defun alg-ang (obj pnt)
      (angle '(0. 0. 0.)
         (vlax-curve-getfirstderiv
           obj
           (vlax-curve-getparamatpoint
             obj
             pnt
           )
         )
      )
    )
     
    (defun answer (quest / wshl ans)
    (or (vl-load-com))
    (setq wshl (vlax-get-or-create-object "WScript.Shell"))
    (setq ans (vlax-invoke-method
      wshl
      'Popup quest 7 "Answer This Question:" vlax-vbYesNo))
    (vlax-release-object wshl)
    (cond  ((= ans 6)
           (setq opt T))
           ((= ans 7)
           (setq opt nil))
           )
      opt
    )
     
     
     
    (defun make-station (bname /  acsp adoc atprom attag at_obj
                 blk_obj hgt lay line_obj sfar )
     
      (vl-load-com)
      (setq    adoc (vla-get-activedocument
               (vlax-get-acad-object)
             )
      )
      (if (and
        (= (getvar "tilemode") 0)
        (= (getvar "cvport") 1)
          )
        (setq acsp (vla-get-paperspace adoc))
        (setq acsp (vla-get-modelspace adoc))
      )
      (vla-startundomark adoc)
     
      (if (not (tblsearch "block" bname))
      (progn
      (setq    attag  "NUMBER" ;(strcase (getstring "\nAttribute tag : \n"))
        atprom "NUMBER" ;(strcase (getstring T "\nAttribute prompt : \n"))
        hgt    1.0 ;(getreal "\nAttribute text height : \n")
      )
     
      (setq lay (getvar "clayer"))
      (setvar "clayer" "0")
      (setvar "attreq" 0)
     
      (setq line_obj (vlax-invoke acsp 'Addline '(0. 0. 0.) (list 0. (* hgt 12.) 0.)))
      (vla-put-color line_obj acyellow)
      (setq    blk_obj    (vla-add (vla-get-blocks adoc) (vlax-3d-point '(0. 0. 0.)) bname)
        sfar    (vlax-safearray-fill
              (vlax-make-safearray vlax-vbObject '(0 . 0))
              (list line_obj)
            )
      )
      (vla-copyobjects adoc sfar blk_obj)
    ;;;  RetVal = object.AddAttribute(Height, Mode, Prompt, InsertionPoint, Tag, Value) 
      (setq at_obj (vla-addattribute blk_obj
             hgt
             acattributemodeverify
             atprom
             (vlax-3d-point '(-0.5 1. 0.))
             attag
             "0+00")
        )
    ;;;  (vla-put-alignment at_obj acAlignmentBottomCenter)
    ;;;  (vla-put-textalignmentpoint
    ;;;    at_obj
    ;;;    (vlax-3d-point '(0. 1. 0.))
    ;;;  )
      (vla-put-rotation at_obj (/ pi 2))
      (vlax-release-object blk_obj)
      )
      (progn
          (princ "\n\t >> Block does already exist!\n")
        (princ)))
      (if (tblsearch "block" bname)
        T
        (progn
          (alert "Impossible to add block")))
      (setvar "attreq" 1)
      (setvar "clayer" lay)
      (vl-catch-all-apply (function (lambda ()(vla-delete line_obj))))
      (vla-regen adoc acactiveviewport)
      (vla-endundomark adoc)
      (vlax-release-object acsp)
      (vlax-release-object adoc)
      (princ)
    )
     
    (or (vl-load-com))
    (defun C:d10 (/    *error*     acsp      adoc       appd        div-error
               len    num     olderror pl       pt        pt_list
               step    util
              )
     
      (or adoc
          (setq adoc
             (vla-get-activedocument
               (vlax-get-acad-object)
             )
          )
      )
      (or appd (setq appd (vla-get-application adoc)))
      (or acsp
          (setq acsp
             (vla-get-block
               (vla-get-activelayout adoc)
             )
          )
      )
      (or util (setq util (vla-get-utility adoc)))
    ;;;  (command "._undo" "_end")
    ;;;  (command "._undo" "_mark")
      (setq olderror *error*)
      (setq *error* div-error)
    ;;;  (setq    bname  (getstring T "\nStation block name : \n"))
    ;;;  (make-station bname)
      (if (not (tblsearch "block" "Station"))
      (make-station "Station"))
     
     
      (vla-getentity
        util
        'pl
        'pt
        "\nSelect line NEAR OF POINT TO START measure: >>> \n"
      )
      (if pl
        (progn
      (setq step (getreal "\nEnter step for stationing <10> : \n"))
      (setq opt (answer "Rotate text perpendicularly to pline?"))
      (if (not step)(setq step 10.))
     
          (setq len    (vlax-curve-getdistatparam
              pl
              (vlax-curve-getendparam pl)
            )
          )
     
          (if (< (distance (vlax-safearray->list pt)
                   (vlax-curve-getstartpoint pl)
             )
             (distance (vlax-safearray->list pt)
                   (vlax-curve-getendpoint pl)
             )
          )
        (setq pt_list (divplus len step))
        (setq pt_list (divminus len step))
          )
     
          (setq
        pt_list    (vl-remove-if
              (function not)
              (mapcar (function (lambda (x)
                          (vlax-curve-getpointatdist pl x)
                        )
                  )
                  pt_list
              )
            )
          )
     
          (setq num 0)
    ;;;      (setq num (getint "\nEnter initial station number\n"))
          (mapcar
        (function
          (lambda (x / dr ang att_list at blk_obj)
            (progn
     
              (setq ang    (alg-ang pl x)
                ang
                (cond ((< (/ pi 2) ang (* pi 1.5)) (+ pi ang))
                      (T ang)
                )
              )
              (setq blk_obj (vlax-invoke
                      acsp 'Insertblock    x "Station" 1 1 1 ang)
              )
              (setq att_list (vlax-invoke blk_obj 'Getattributes))
              (foreach at att_list
            (if (eq (vlax-get at 'Tagstring) "NUMBER")
              (progn
                (vlax-put at 'Textstring (if (< num 990.)
        (strcat "sta: 0+" (rtos num 2 2))
    (strcat "sta: "
        (itoa (fix (/ num 1000.)));<--- changes 1200. on num (typo)
        "+"
        (rtos (- num (* (fix (/ num 1000.)) 1000)) 2 2)
        )
    ))
                (if (not opt)
                (vlax-put at 'Rotation 0))
                (vla-update at)
              )
            )
              )
              (vla-update blk_obj)
              (vlax-release-object blk_obj)
              (setq num (+ num step))
            )
          )
        )
        pt_list
          )
     
          (if (not (vlax-object-released-p pl))
        (vlax-release-object pl)
          )
        )
        (princ "\nNothing selected try again\n")
      )
      (vla-zoomextents appd)
      (vla-regen adoc acactiveviewport)
      (setq    *error*    olderror
        div-error nil
      )
    ;;;  (command "._undo" "_end")
      (princ)
    )
    (prompt "\n")
    (prompt "\n    ***    Type D10 to execute    *** \n")
    (princ)
    ~'J'~
    Last edited by fixo; 16th Jan 2012 at 05:32 pm. Reason: typo has been found
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  6. #6
    Senior Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    267

    Default

    thank you fixo you only i want to explain my idea
    your routin very great but when measuring reach to one thousnd there is mistake here so total length not correct please modify it
    thanks

  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,684

    Default

    Quote Originally Posted by motee-z View Post
    thank you fixo you only i want to explain my idea
    your routin very great but when measuring reach to one thousnd there is mistake here so total length not correct please modify it
    thanks
    Sorry, I'm busy at the moment
    Perhaps, later I can do it

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

  8. #8
    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,684

    Default

    Forgot to say about
    I wan't to work with your picture
    Upload here your real working drawing
    that would be much easier to help you

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

  9. #9
    Senior Member
    Using
    not specified
    Join Date
    Feb 2006
    Posts
    267

    Default

    thank you fixo for your help
    thanks to carlB for the link it solved what i need exactly

  10. #10
    Senior Member Cymro's Avatar
    Using
    AutoCAD 2008
    Join Date
    Jul 2006
    Location
    Gwynedd Wales
    Posts
    165

    Default

    Registered forum members do not see this ad.

    Thanks for this excellent routine.
    One thing if anyone could help me, what do I need to change in the routine to rotate the text of the chainages by 180 degrees.

    many thanks

    Cymro
    Last edited by Cymro; 22nd May 2010 at 12:17 pm.

Similar Threads

  1. Join 2d polyline to 3d polyline
    By Tconn in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 12th Jul 2007, 05:59 pm
  2. Create array from text to draw polyline
    By Nugg in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 8th May 2007, 02:29 am
  3. How do I draw a 3D boxes along 3D polyline
    By free2fly in forum AutoCAD General
    Replies: 3
    Last Post: 5th Jan 2006, 07:12 am
  4. how do you draw..
    By James281 in forum AutoCAD General
    Replies: 3
    Last Post: 16th Nov 2005, 12:09 am
  5. how to draw in 3d
    By Dan in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 6th Dec 2002, 10: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