Then simply calculate each point at 90 degree from this angle.
with the help of ymg this is the idea. I dont know how to continue. Can any one finish this code.I am not good in lisp . I have a lot of work to do and this code will help me a lot.You really have to start trying to write your own code. ;)Code - Auto/Visual Lisp: [Select]
;; Read the file with the distanse and elevetion ;; ; ;; Return angle along curve, at specified point (on curve) ; ;; e - valid curve (ENAME or VLA-OBJECT) ; ;; p - point on curve ; ;; Alan J. Thompson, 11.04.10 ; ;; ; ) ;; Save the new file p,x,y,z
Thanks
Always ronjonp your comments are negative. Can you help me one time without doing me an observation? We're not all good in programming as you !!!! :)Negative (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=chainage%20site%3Atheswamp.org).
(defun c:section2points (/ ** an en f fname lg p path pnum ps rst sect title
angleatpoint readcsv in_range rtosta)
;; ;
;; Return angle along curve, at specified point (on curve) ;
;; e - valid curve (ENAME or VLA-OBJECT) ;
;; p - point on curve ;
;; Alan J. Thompson, 11.04.10 ;
;; ;
(defun AngleAtPoint (e p)
(angle '(0. 0. 0.) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e p)))
)
;; ReadCSV - Lee Mac ;
;; Parses a CSV file into a list of lists, each sublist is a row ;
;; of CSV cell values. ;
(defun ReadCSV ( filename / _csv->lst file line lst )
(defun _csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
(cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
(list str)
)
)
(if (setq file (open filename "r"))
(progn
(while (setq line (read-line file))
(setq lst (cons (_csv->lst line) lst))
)
(close file)
)
)
(reverse lst)
)
;; ;
;; in_range by ElpanovEvgeniy (recursive) ;
;; ;
;; Similar to the Python Function ;
;; ;
(defun in_range (s e i)
(if (or (and (> i 0) (< s e)) (and (< i 0) (> s e)))
(cons s (in_range (+ i s) e i))
)
)
;; ;
;; rtosta by ymg September 2013 ;
;; Arguments: sta, Real number to format as a Station ;
;; unit, 1 for Imperials, ;
;; 2 for Metrics. ;
;; prec, Integer for number of decimals ;
;; DIMZIN must be set to 0 or 1 outside this routine. ;
;; ;
;; Examples: (rtosta 0 1 0) -> "0+00" (rtosta 1328.325 1 2) -> "13+28.33";
;; (rtosta 0 2 0) -> "0+000" (rtosta 1328.325 2 2) -> "1+328.33";
;; ;
;; If sta is negative, format is as follow: ;
;; (rtosta -1328.325 1 2) -> "13-28.33" ;
;; (rtosta -1328.325 2 2) -> "1-328.33" ;
;; ;
(defun rtosta (sta unit prec / str a b dz)
(setq str (rtos (abs sta) 2 prec))
(while (< (strlen str) (if (= prec 0) (+ unit 2) (+ prec (+ unit 3))))
(setq str (strcat "0" str))
)
(setq a (if (= prec 0) (- (strlen str) unit) (- (strlen str) prec (+ unit 1)))
b (substr str 1 (- a 1))
a (substr str a)
)
(strcat b (if (minusp sta) "-" "+") a)
)
;;-------------------------- Main Program ---------------------------------;
(setq en (car (entsel "\nSelect the Polyline Representing the Alignment: "))
lg (vlax-curve-getdistatpoint en (vlax-curve-getendpoint en))
pnum 1
path ""
)
(foreach d (in_range 0 lg 20)
(setq title (strcat "Select File for Chainage " (rtosta d 2 0))
** (princ (strcat "\n" title))
fname (getfiled title path "txt" 0)
path (if (setq tmp (vl-filename-directory fname)) (strcat tmp "\\") "")
)
(if fname
(progn
(setq sect (readcsv fname)
p (vlax-curve-getpointatdist en d)
an (+ (angleatpoint en p) (/ pi 2))
)
(foreach i sect
(setq ps (polar p an (atof (car i)))
rst (cons (list pnum (car ps) (cadr ps) (atof (cadr i))) rst)
pnum (1+ pnum)
)
)
)
)
)
;; List rst now contains all points generated from the section ;
(setq f (open (strcat path "Section Points.txt") "w"))
(foreach i (reverse rst)
(write-line (strcat (itoa (car i)) ","
(rtos (cadr i)) ","
(rtos (caddr i)) ","
(rtos (cadddr i))
)
f
)
)
(close f)
(princ)
)
0+000 <--- chainage
-3.91192198,22.42945290
-3.65605593,22.60003090
-3.35605597,22.60003090
-3.05302572,22.80002975
-2.50000000,22.80002403
0.00000000,22.79999924 <--- Here is the section of roadlinea and cross section line
2.50000000,22.80002403
3.05302572,22.80002975
3.35605597,22.60003090
3.65605593,22.60003090
4.25976181,23.80744362
4.55976200,24.23544121
4.85951757,24.49160957
0+020<--- chainage
-4.01208448,21.47536469
-3.65605593,21.71271896
-3.35605597,21.71271896
-3.05302572,21.91271782
-2.50000000,21.91271210
0.00000000,21.91268730
2.50000000,21.91271210
3.05302572,21.91271782
3.35605597,21.71271896
3.65605593,21.71271896
3.73025107,21.86110687
4.03025103,22.28760529
4.33002567,22.54076385
(princ (strcat (rtos (car pnt) 2 8) ","
(rtos (cadr pnt) 2 8)) fh)
(princ (strcat (rtos (car pnt) 2 3) ","
(rtos (cadr pnt) 2 2)) fh)
an (- (angleatpoint en p) (/ pi 2))
an (- (angleatpoint en p) (/ pi 200))
I change the angle toCode: [Select]an (- (angleatpoint en p) (/ pi 200))
Now the angle is almost correct but all the points must move to right, because the number 6 is not in the middle of the road
Hi Kerry i write (/ pi 200)to convert the angle to grads
All the times the program take as midle insert point the right side of the section line. The problem is if i extent the section line to the left and right the road center line is not all ways in the middle of the cross section line. Thats way i said in the beginning of the topic to
1) select the cross section line
2)pick the middle of green cross section line from the road drawing
3)calculate the angle G in grads
http://m.youtube.com/watch?v=pHte24GGHD4
:-)http://m.youtube.com/watch?v=pHte24GGHD4
The cat has lovely coloured sclera.
I plotted your sample section and point 1, 6 and 13 are right, no matter the direction or angle units.
;;The distance along the curve from the beginning of the curve to the location of the specified point.
(setq pt (vlax-curve-getPointAtDist en 20)) ;=> (17.5001 -9.6823 0.0)
Quote;;The distance along the curve from the beginning of the curve to the location of the specified point.
(setq pt (vlax-curve-getPointAtDist en 20)) ;=> (17.5001 -9.6823 0.0)
I have one question. This lisp works only for cross section with length 20m ? If i have 20m for the left of the road center line and 40m for the right how the program will understand were is the center of the road?
I told you many times that the angle argument for function polar is radians. You don't need grad the side of your direction is also irrelevant.
And why ymg sayQuoteI told you many times that the angle argument for function polar is radians. You don't need grad the side of your direction is also irrelevant.
You do not need to pick each point, the programs
find them at every 20 meters.
You do have to enter a filename in the getfiled dialog box,
because you did not organize your data properly. The section
should be in a single folder and at least have a name that could
be translated to a chainage. Alternatively the first line in every
cross section file could be a real corresponding to the chainage.
You do not need to pick each point, the programs
find them at every 20 meters.
Another question, although you are not very good at answering, Why don't you
named your file in a meaningful way, like including the chainage in the name of the file ?
To do this, each cross section should have as the first line in each file, the chainage and the
coordinates of the center point and the orientation of the section. All the offsets and distances
would be kept in the following lines.
This way you would need nothing else to re-calculate your points. If you go back
to a project two years down the line, your alignment can be reconstructed from
the cross-section files only.
Another question, although you are not very good at answering, Why don't you
named your file in a meaningful way, like including the chainage in the name of the file ?
;; List rst now contains all points generated from the section ;
(setq f1 (getfiled "Section Points Pxyz" "/" "txt" 1))
(setq f (open f1 "w"))
(foreach i (reverse rst)
(write-line (strcat (itoa (car i)) ","
(rtos (cadr i)) ","
(rtos (caddr i)) ","
(rtos (cadddr i))
)
f
)
)
(close f)
(princ)
)
Select the Chainage marker line:
Select Intersection Point of Road Alignment and Chainage marker _int of ; error: no function definition: READCSV
Command:
I did this change in your code
< .. >
Section Points A13.txt
1,428782.778500,4315790.148924,13.33
2,428782.866375,4315790.262038,13.42
3,428783.050423,4315790.498948,13.42
4,428783.236329,4315790.738251,13.62
5,428783.575606,4315791.174976,13.62
6,428785.109337,4315793.149228,13.62
7,428786.643068,4315795.123479,13.62
8,428786.982345,4315795.560204,13.62
9,428787.168252,4315795.799507,13.42
10,428787.352300,4315796.036418,13.42
11,428787.545433,4315796.285023,13.21