Message 1 of 20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Friends,
I Have Chainage in Excel file How to mark on polyline and export to coordinate to chainage
Solved! Go to Solution.
Dear Friends,
I Have Chainage in Excel file How to mark on polyline and export to coordinate to chainage
Solved! Go to Solution.
On this polyline i require the chainage provided in excel in text format with any attribute block
If you convert in CSV file with this form: not tile, with decimal point and not comma
exemple:
22404.9; 22470.72; 23397.853; 23476.193; 28595.116; 28655.904; 31532.042; 31578.282; 31684.821; 32656.607; 32685.727; 32920.045; 33539.855; 34814.419; 36463.313; 39310.654; 43065.435; 45110.463; 46023.238; 47548.831; 47611.981; 49064.194; 50295.883; 50418.112; 50683.444;
Then you can use this:
(defun draw_pt (pt col / rap) (setq rap (/ (getvar "viewsize") 50)) (foreach n (mapcar '(lambda (x) (list ((eval (car x)) (car pt) rap) ((eval (cadr x)) (cadr pt) rap) (caddr pt) ) ) '((+ +) (+ -) (- +) (- -)) ) (grdraw pt n col) ) ) (defun c:measure_on_curve_whith_CSV ( / js ent dxf_ent vla_obj param_end perim_obj pt_ref dist_ref op input f_open l_read len_vtx new_pt) (vl-load-com) (princ "\nSelect a curvilinear object on which you want to measure.") (while (not (setq js (ssget "_+.:E:S" (list (cons -4 "<OR") (cons -4 "<AND") (cons 0 "*POLYLINE,LINE,ARC,CIRCLE,ELLIPSE") (cons -4 "<NOT") (cons -4 "&") (cons 70 112) (cons -4 "NOT>") (cons -4 "AND>") (cons 0 "SPLINE") (cons -4 "OR>") ) ) ) ) ) (setq ent (ssname js 0) dxf_ent (entget ent) vla_obj (vlax-ename->vla-object ent) param_end (vlax-curve-getEndParam vla_obj) perim_obj (vlax-curve-getDistAtParam vla_obj param_end) ) (redraw ent 3) (initget 1) (setq pt_ref (getpoint "\nReference point of the measure: ") pt_ref (vlax-curve-getClosestPointTo vla_obj (trans pt_ref 1 0)) ) (draw_pt (trans pt_ref 0 1) 1) (setq dist_ref (vlax-curve-getDistAtPoint vla_obj pt_ref)) (initget "+ -") (setq op (getkword "\nAdd-Subtract [+/-]? <+>: ")) (if (or (eq op "+") (not op)) (setq op '+) (setq op '-)) (setq input (getfiled "Select a CSV file" "" "csv" 2) f_open (open input "r") ) (while (setq l_read (read-line f_open)) (setq len_vtx (atof (substr l_read 1 (vl-string-position 59 l_read)))) (cond ((<= len_vtx perim_obj) (if (or (null (setq new_pt (vlax-curve-getPointAtDist vla_obj (+ dist_ref len_vtx)))) (> ((eval op) dist_ref len_vtx) perim_obj)) (setq new_pt (vlax-curve-getPointAtDist vla_obj (- dist_ref len_vtx))) ) (draw_pt (trans new_pt 0 1) 3) (if (and (<= ((eval op) dist_ref len_vtx) perim_obj) (>= ((eval op) dist_ref len_vtx) 0.0)) (setq new_pt (vlax-curve-getPointAtDist vla_obj ((eval op) dist_ref len_vtx))) (setq new_pt nil) ) (if new_pt (progn (redraw) (draw_pt (trans pt_ref 0 1) 1) (draw_pt (trans new_pt 0 1) 3)) (progn (redraw) (draw_pt (trans pt_ref 0 1) 1)) ) (redraw) (if new_pt (entmake (list '(0 . "POINT") '(100 . "AcDbEntity") (assoc 67 dxf_ent) (assoc 410 dxf_ent) (cons 8 (getvar "CLAYER")) (cons 10 new_pt) '(210 0.0 0.0 1.0) '(50 . 0.0) ) ) ) ) (T (princ "\nThe introduced length is larger than the object.") ) ) ) (close f_open) (redraw ent 4) (prin1) )
You may use https://www.cadstudio.cz/en/download.asp?file=TraceCurve
You may use block or point. In each iteration you enter distance to next chainage point.
Miljenko Hatlak
This lisp only plot points Please help me for plot any chainage attribute block
thanks CADaStroumph for the help
This?
With your block present in your drawing.
(defun draw_pt (pt col / rap) (setq rap (/ (getvar "viewsize") 50)) (foreach n (mapcar '(lambda (x) (list ((eval (car x)) (car pt) rap) ((eval (cadr x)) (cadr pt) rap) (caddr pt) ) ) '((+ +) (+ -) (- +) (- -)) ) (grdraw pt n col) ) ) (defun c:measure_on_curve_whith_CSV ( / js ent dxf_ent vla_obj param_end perim_obj pt_ref dist_ref op input f_open l_read len_vtx ang new_pt) (vl-load-com) (princ "\nSelect a curvilinear object on which you want to measure.") (while (not (setq js (ssget "_+.:E:S" (list (cons -4 "<OR") (cons -4 "<AND") (cons 0 "*POLYLINE,LINE,ARC,CIRCLE,ELLIPSE") (cons -4 "<NOT") (cons -4 "&") (cons 70 112) (cons -4 "NOT>") (cons -4 "AND>") (cons 0 "SPLINE") (cons -4 "OR>") ) ) ) ) ) (setq ent (ssname js 0) dxf_ent (entget ent) vla_obj (vlax-ename->vla-object ent) param_end (vlax-curve-getEndParam vla_obj) perim_obj (vlax-curve-getDistAtParam vla_obj param_end) ) (redraw ent 3) (initget 1) (setq pt_ref (getpoint "\nReference point of the measure: ") pt_ref (vlax-curve-getClosestPointTo vla_obj (trans pt_ref 1 0)) ) (draw_pt (trans pt_ref 0 1) 1) (setq dist_ref (vlax-curve-getDistAtPoint vla_obj pt_ref)) (initget "+ -") (setq op (getkword "\nAdd-Subtract [+/-]? <+>: ")) (if (or (eq op "+") (not op)) (setq op '+) (setq op '-)) (setq input (getfiled "Select a CSV file" "" "csv" 2) f_open (open input "r") ) (while (setq l_read (read-line f_open)) (setq len_vtx (atof (substr l_read 1 (vl-string-position 59 l_read)))) (cond ((<= len_vtx perim_obj) (if (or (null (setq new_pt (vlax-curve-getPointAtDist vla_obj (+ dist_ref len_vtx)))) (> ((eval op) dist_ref len_vtx) perim_obj)) (setq new_pt (vlax-curve-getPointAtDist vla_obj (- dist_ref len_vtx))) ) (draw_pt (trans new_pt 0 1) 3) (if (and (<= ((eval op) dist_ref len_vtx) perim_obj) (>= ((eval op) dist_ref len_vtx) 0.0)) (setq new_pt (vlax-curve-getPointAtDist vla_obj ((eval op) dist_ref len_vtx))) (setq new_pt nil) ) (if new_pt (progn (redraw) (draw_pt (trans pt_ref 0 1) 1) (draw_pt (trans new_pt 0 1) 3)) (progn (redraw) (draw_pt (trans pt_ref 0 1) 1)) ) (redraw) (if new_pt (progn (setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv vla_obj (vlax-curve-getParamAtPoint vla_obj new_pt)))) (entmake (list (cons 0 "INSERT") (cons 100 "AcDbEntity") (assoc 67 dxf_ent) (assoc 410 dxf_ent) (cons 8 (getvar "CLAYER")) (cons 100 "AcDbBlockReference") (cons 66 1) (cons 2 "BLK_MEASURE_CURVE") (cons 10 new_pt) (cons 41 1.0) (cons 42 1.0) (cons 43 1.0) (cons 50 ang) ) ) (entmake (list (cons 0 "ATTRIB") (cons 100 "AcDbEntity") (assoc 67 dxf_ent) (assoc 410 dxf_ent) (cons 8 (getvar "CLAYER")) (cons 62 1) (cons 100 "AcDbText") (cons 10 (polar (polar new_pt (- ang (* 0.5 pi)) 15.9313) (- ang) 3.3679 ) ) (cons 40 3.175) (cons 1 (rtos (/ len_vtx 1000.0) 2 3)) (cons 50 ang) (cons 41 1.0) (cons 51 0.0) (cons 7 "$BLK_MEAS") (cons 71 0) (cons 72 1) (cons 11 (polar new_pt (- ang (* 0.5 pi)) 16.9213)) (cons 100 "AcDbAttribute") (cons 2 "KM") (cons 70 0) (cons 73 0) (cons 74 1) ) ) (entmake (list (cons 0 "SEQEND") (cons 8 (getvar "CLAYER")) (cons 62 0) (cons 6 "ByLayer") (cons 370 -2))) ) ) ) (T (princ "\nThe introduced length is larger than the object.") ) ) ) (close f_open) (redraw ent 4) (prin1) )
🙏Thanks CADaStroumph Sir 🙏
what is the name of this lisp file how to run it????
Save code into somefile.lisp. Load it to autocad - tools -> load application-..... When loaded type measure_on_curve_whith_CSV to console.
Miljenko Hatlak
i need to insert one block in aligned position on a polyline at the distances mentioned in .csv file
can you help me with this ??
Start new post with full details of your request. Attach sample file with sample block you use. I will work on it later today (currently at work).
Miljenko Hatlak
i have to insert 1000 of blocks in similar way so need your help to develop lisp for the same
When I asked you to start new post I wanted you to start new post to this forum and not just reply to this topic with your request. That way each OP request is solved separately, you have an option to select one or more solutions to your particular problem, and its much easier to other readers to follow requests.
Miljenko Hatlak
if you check i have already posted this request sever time but no one responded ..and here similar type of lisp this guy has prepared thats why i have posted here
you can check my new request where no one posted solution neither any response
Sir,
I have attached the original excel file and Autocad version for your reference. actually, I need to export (Label) all chainages which are in the excel file, to the alignment in the attached Autocad drawing.
Your xls data have 3 repited distances for each one , how do you want to do ?
12548 |
12548 |
12548 |
15000 |
15000 |
15000 |
15300 |
15300 |
15300 |
15400 |
15400 |
15400 |
18000 |
18000 |
18000 |
18524 |
18524 |
18524 |
19528 |
19528 |
19528 |
21000 |
21000 |
21000 |
21546 |
21546 |
21546 |
22000 |
22000 |
22000 |
23512 |
23512 |
23512 |
25000 |
25000 |
25000 |
25142 |
25142 |
25142 |
25212 |
25212 |
25212 |
25422 |
25422 |
25422 |
26250 |
26250 |
26250 |
28000 |
28000 |
28000 |
35000 |
35000 |
35000 |
35201 |
35201 |
35201 |
36236 |
36236 |
36236 |
45112 |
45112 |
45112 |
51425 |
51425 |
51425 |
52152 |
52152 |
52152 |
68000 |
68000 |
68000 |
Sir,
Thank you for your query ....the distances are random and not repeated its just a sample excel data
so the input distance can be random distances.
Nilesh