I Have Chainage in Excel file How to mark on polyline and export to coordinate t

I Have Chainage in Excel file How to mark on polyline and export to coordinate t

bit_Cad2018
Advocate Advocate
3,006 Views
19 Replies
Message 1 of 20

I Have Chainage in Excel file How to mark on polyline and export to coordinate t

bit_Cad2018
Advocate
Advocate

Dear Friends,
I Have Chainage in Excel file How to mark on polyline and export to coordinate to chainage

 

 

0 Likes
Accepted solutions (1)
3,007 Views
19 Replies
Replies (19)
Message 2 of 20

devitg
Advisor
Advisor

Please Upload , both XLS and DWG where to apply , and how do you mean to do it. 

Message 3 of 20

bit_Cad2018
Advocate
Advocate

On this polyline i require the chainage provided in excel in text format with any attribute block

0 Likes
Message 4 of 20

devitg
Advisor
Advisor

please supply such block with attributes 

0 Likes
Message 5 of 20

CADaSchtroumpf
Advisor
Advisor

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)
)
Message 6 of 20

hak_vz
Advisor
Advisor

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

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 7 of 20

bit_Cad2018
Advocate
Advocate

This lisp only plot points Please help me for plot any chainage attribute block

 

thanks  CADaStroumph  for the help

0 Likes
Message 8 of 20

CADaSchtroumpf
Advisor
Advisor
Accepted solution

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)
)
0 Likes
Message 9 of 20

bit_Cad2018
Advocate
Advocate

🙏Thanks CADaStroumph Sir 🙏

 

0 Likes
Message 10 of 20

nilesh.bhosale
Advocate
Advocate

what is the name of this lisp file how to run it????

0 Likes
Message 11 of 20

hak_vz
Advisor
Advisor

@nilesh.bhosale 

Save code into somefile.lisp.  Load it to autocad - tools -> load application-.....  When loaded type measure_on_curve_whith_CSV to console.

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 12 of 20

nilesh.bhosale
Advocate
Advocate

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 ??

 

 

0 Likes
Message 13 of 20

hak_vz
Advisor
Advisor

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

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 14 of 20

nilesh.bhosale
Advocate
Advocate

Dear  hak vz

please see attached cad file for polyline and block to be inserted on polyline aligned and also the csv file attached in which distance marked 

0 Likes
Message 15 of 20

nilesh.bhosale
Advocate
Advocate

i have to insert 1000 of blocks in similar way so need your help to develop lisp for the same

0 Likes
Message 16 of 20

hak_vz
Advisor
Advisor

@nilesh.bhosale 

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.

 

Untitled.png

 

Visual lisp forum 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 17 of 20

nilesh.bhosale
Advocate
Advocate

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

0 Likes
Message 18 of 20

bilu09
Contributor
Contributor

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. 

0 Likes
Message 19 of 20

devitg
Advisor
Advisor

@nilesh.bhosale 

 

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

 

0 Likes
Message 20 of 20

nilesh.bhosale
Advocate
Advocate

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

0 Likes