Author Topic: Centre Line Chainage Mark & Text  (Read 10800 times)

0 Members and 1 Guest are viewing this topic.

scottcd

  • Newt
  • Posts: 52
Centre Line Chainage Mark & Text
« on: August 22, 2008, 09:55:54 AM »
I was thinking about writing a lisp to create a chainage mark & text along a proposed road centreline using the measure command.
I have run into problems straight away with measure because it does not allow the attribute to be edited.

Is there a better way to calc the chainage points eg every 10m  along the polyline and then insert my chainage mark etc.

Cheers

Scott

AutoCAD Dos R9 - 2018 and BricCAD 18.2

Gliderider

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #1 on: August 22, 2008, 10:33:56 AM »
Try looking here http://afralisp.net/lisp/dctools.htm, might give you some ideas

mjguzik

  • Newt
  • Posts: 30
Re: Centre Line Chainage Mark & Text
« Reply #2 on: August 22, 2008, 10:55:19 PM »
Examine the following vlisp functions:

vlax-curve-getPointAtDist for distance,
vlax-curve-getParamAtDist for parameter at distance,
and with the parameter use vlax-curve-getFirstDeriv to get the tangent vector at distance. 

Put these in a loop over the length and you should be there.

MJG

sinc

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #3 on: August 23, 2008, 08:09:33 AM »
Why not just shell out the $7500 for a seat of Civil-3D?    :lol:

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Centre Line Chainage Mark & Text
« Reply #4 on: August 23, 2008, 12:52:06 PM »
Why not just shell out the $7500 for a seat of Civil-3D?    :lol:

I almost thought the same thing....
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Dinosaur

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #5 on: August 23, 2008, 01:13:02 PM »
I know of a company that had a project doing R-O-W maps for fiber optic lines.  The work was completely done with no frills MicroStation except for this very task.  They had purchased a seat of EaglePoint just to perform this single function.

SomeCallMeDave

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #6 on: August 23, 2008, 01:39:49 PM »
Don't spend $7,500 for Civil3D.

Send me the file and I will do it for $7,400  :lmao:

SomeCallMeDave

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #7 on: August 23, 2008, 02:09:14 PM »
But seriously,  here is a quickie to get you started.  Needs many things, but it might give you some ideas

Code: [Select]
(defun c:ChainageMark()
    (setq Pl1Name (car (entsel"\nPick Centerline "))
          StaInterval (getreal "\nEnter Chainage Interval ")
          MarkLength (getreal "\nEnter Tick Length ")
          CurrStation StaInterval ; change to 0 if mark is needed at start of pline
          MaxLength (vlax-curve-getDistAtPoint Pl1Name (vlax-curve-getEndPoint Pl1Name))
          currLayer (getvar "CLAYER") ; change as needed
    );setq
    (while (< CurrStation MaxLength)
         (setq currPoint (vlax-curve-getPointAtDist Pl1Name currStation)
               currParam (vlax-curve-getParamAtDist Pl1Name currStation)
               PerpAng (dkb_getPerp Pl1Name currParam 1)
               Pt1 (polar currPoint PerpAng (* MarkLength 0.5))
               Pt2 (polar currPoint PerpAng (* MarkLength -0.5))
               currStation (+ currStation StaInterval)
               LineList (list
                          '(0 . "LINE")
                          '(100 . "AcDbEntity")
                          '(100 . "AcDbLine")
                          (cons 8 currLayer)
                          (cons 10 Pt1)
                          (cons 11 Pt2)
                     );list
         );setq
         (entmake LineList)
   
    );while

); defun chainageMark

(defun dkb_getPerp (pCurve pParam pDir / ang1 oCurve zeroPt deg90 Bulge1 FirstDeriv pt1 Rp1 )
    ;; function to return the perpindicular angle of a Pline at a given parameter and a direction left or right based
    ;; on looking up-station left=-1  right = 1
   
    (setq oCurve (dkb_getOrCreateVlaObject pCurve)
          zeroPt '(0.0 0.0 0.0)
          deg90 (atan 1 0)
          FirstDeriv (vlax-curve-getFirstDeriv oCurve pParam)
          ang1 (angle zeroPt FirstDeriv)
          ;;correct for the desired side of the line
          ang1 (+ ang1 (* -1 pDir deg90))
    );setq
);defun end function dkb_getPerp

(defun dkb_GetOrCreateVlaObject(pEntOrObj / oPl)
     (if (not (equal (type pEntOrObj) 'VLA-OBJECT))
       (setq oPl (vlax-ename->vla-object pEntOrObj))
       (setq oPl pEntOrObj)
     ); if
    oPl
);defun dkb_GetorCreateVlaOjbect

(prin1);load cleanly




Scott

  • Bull Frog
  • Posts: 244
Re: Centre Line Chainage Mark & Text
« Reply #8 on: August 23, 2008, 09:55:40 PM »
Give this a try.  Can't remember who helped me with this, so if you recognize the work, give credit to whoever deserves it.

The centerline can be a line or polyline.
« Last Edit: August 23, 2008, 09:59:43 PM by Scott »

pedroantonio

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #9 on: May 07, 2015, 12:27:13 PM »
Hi  SomeCallMeDave , nice code
1) Can anyone update this code to add texts and points (for example D1,D2,D3 ....)
2) When i run the lisp code and selecto the polyline it doesn't add line at the beginnig look the attach

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ChainageMark()
  2.     (setq Pl1Name (car (entsel"\nPick Centerline "))
  3.           StaInterval (getreal "\nEnter Chainage Interval ")
  4.           MarkLength (getreal "\nEnter Tick Length ")
  5.           CurrStation StaInterval ; change to 0 if mark is needed at start of pline
  6.           MaxLength (vlax-curve-getDistAtPoint Pl1Name (vlax-curve-getEndPoint Pl1Name))
  7.           currLayer (getvar "CLAYER") ; change as needed
  8.     );setq
  9.     (while (< CurrStation MaxLength)
  10.          (setq currPoint (vlax-curve-getPointAtDist Pl1Name currStation)
  11.                currParam (vlax-curve-getParamAtDist Pl1Name currStation)
  12.                PerpAng (dkb_getPerp Pl1Name currParam 1)
  13.                Pt1 (polar currPoint PerpAng (* MarkLength 0.5))
  14.                Pt2 (polar currPoint PerpAng (* MarkLength -0.5))
  15.                currStation (+ currStation StaInterval)
  16.                LineList (list
  17.                           '(0 . "LINE")
  18.                           '(100 . "AcDbEntity")
  19.                           '(100 . "AcDbLine")
  20.                           (cons 8 currLayer)
  21.                           (cons 10 Pt1)
  22.                           (cons 11 Pt2)
  23.                      );list
  24.          );setq
  25.          (entmake LineList)
  26.    
  27.     );while
  28.  
  29. ); defun chainageMark
  30.  
  31. (defun dkb_getPerp (pCurve pParam pDir / ang1 oCurve zeroPt deg90 Bulge1 FirstDeriv pt1 Rp1 )
  32.     ;; function to return the perpindicular angle of a Pline at a given parameter and a direction left or right based
  33.     ;; on looking up-station left=-1  right = 1
  34.    
  35.     (setq oCurve (dkb_getOrCreateVlaObject pCurve)
  36.           zeroPt '(0.0 0.0 0.0)
  37.           deg90 (atan 1 0)
  38.           FirstDeriv (vlax-curve-getFirstDeriv oCurve pParam)
  39.           ang1 (angle zeroPt FirstDeriv)
  40.           ;;correct for the desired side of the line
  41.           ang1 (+ ang1 (* -1 pDir deg90))
  42.     );setq
  43. );defun end function dkb_getPerp
  44.  
  45. (defun dkb_GetOrCreateVlaObject(pEntOrObj / oPl)
  46.      (if (not (equal (type pEntOrObj) 'VLA-OBJECT))
  47.        (setq oPl (vlax-ename->vla-object pEntOrObj))
  48.        (setq oPl pEntOrObj)
  49.      ); if
  50.     oPl
  51. );defun dkb_GetorCreateVlaOjbect
  52.  
  53. (prin1);load cleanly
  54.  
  55.  

Thanks

ymg

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #10 on: May 07, 2015, 01:45:20 PM »
topographer,

For the first problem, I believe everything is in there so that you can do it
yourself. Directions and locations are already available in the code  posted.

For the second problem if you so much as look at the code, there is a nice remark
that tells you how to settle it.

You have to help yourself a little and start a bit of coding.
Learn to fish.

ymg


ronjonp

  • Needs a day job
  • Posts: 7526
Re: Centre Line Chainage Mark & Text
« Reply #11 on: May 07, 2015, 02:43:36 PM »
topographer,

....

You have to help yourself a little and start a bit of coding.
Learn to fish.

ymg
Don't hold your breathe.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #12 on: May 07, 2015, 04:22:59 PM »
I can't  understand this

Quote
CurrStation StaInterval ; change to 0 if mark is needed at start of pline

I write this and gives me error

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ChainageMark()
  2.     (setq Pl1Name (car (entsel"\nPick Centerline "))
  3.           StaInterval (getreal "\nEnter Chainage Interval ")
  4.           MarkLength (getreal "\nEnter Tick Length ")
  5.  CurrStation StaInterval 0 ; change to 0 if mark is needed at start of pline
  6.           MaxLength (vlax-curve-getDistAtPoint Pl1Name (vlax-curve-getEndPoint Pl1Name))
  7.           currLayer (getvar "CLAYER") ; change as needed
  8.     );setq
  9.     (while (< CurrStation MaxLength)
  10.          (setq currPoint (vlax-curve-getPointAtDist Pl1Name currStation)
  11.                currParam (vlax-curve-getParamAtDist Pl1Name currStation)
  12.                PerpAng (dkb_getPerp Pl1Name currParam 1)
  13.                Pt1 (polar currPoint PerpAng (* MarkLength 0.5))
  14.                Pt2 (polar currPoint PerpAng (* MarkLength -0.5))
  15.                currStation (+ currStation StaInterval)
  16.                LineList (list
  17.                           '(0 . "LINE")
  18.                           '(100 . "AcDbEntity")
  19.                           '(100 . "AcDbLine")
  20.                           (cons 8 currLayer)
  21.                           (cons 10 Pt1)
  22.                           (cons 11 Pt2)
  23.                      );list
  24.          );setq
  25.          (entmake LineList)
  26.  
  27.     );while
  28.  
  29. ); defun chainageMark
  30.  
  31. (defun dkb_getPerp (pCurve pParam pDir / ang1 oCurve zeroPt deg90 Bulge1 FirstDeriv pt1 Rp1 )
  32.     ;; function to return the perpindicular angle of a Pline at a given parameter and a direction left or right based
  33.     ;; on looking up-station left=-1  right = 1
  34.  
  35.     (setq oCurve (dkb_getOrCreateVlaObject pCurve)
  36.           zeroPt '(0.0 0.0 0.0)
  37.           deg90 (atan 1 0)
  38.           FirstDeriv (vlax-curve-getFirstDeriv oCurve pParam)
  39.           ang1 (angle zeroPt FirstDeriv)
  40.           ;;correct for the desired side of the line
  41.           ang1 (+ ang1 (* -1 pDir deg90))
  42.     );setq
  43. );defun end function dkb_getPerp
  44.  
  45. (defun dkb_GetOrCreateVlaObject(pEntOrObj / oPl)
  46.      (if (not (equal (type pEntOrObj) 'VLA-OBJECT))
  47.        (setq oPl (vlax-ename->vla-object pEntOrObj))
  48.        (setq oPl pEntOrObj)
  49.      ); if
  50.     oPl
  51. );defun dkb_GetorCreateVlaOjbect
  52.  
  53. (prin1);load cleanly
  54.  
  55.  

ymg

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #13 on: May 07, 2015, 07:31:25 PM »
Code: [Select]
(setq Pl1Name (car (entsel"\nPick Centerline "))
          StaInterval (getreal "\nEnter Chainage Interval ")
          MarkLength (getreal "\nEnter Tick Length ")
          CurrStation  0 ; change to 0 if mark is needed at start of pline
          MaxLength (vlax-curve-getDistAtPoint Pl1Name (vlax-curve-getEndPoint Pl1Name))
          currLayer (getvar "CLAYER") ; change as needed
    );set

ymg

pedroantonio

  • Guest
Re: Centre Line Chainage Mark & Text
« Reply #14 on: May 08, 2015, 02:29:16 AM »
Thanks ymg