Polyline on chainage with block

Polyline on chainage with block

bit_Cad2018
Advocate Advocate
2,383 Views
12 Replies
Message 1 of 13

Polyline on chainage with block

bit_Cad2018
Advocate
Advocate

please help me Require on polyline all  circle point chainage along pipeline with block

 

 

i given by marko_ribar code 

code its extremely good only one change arrow & Text use this i request block

 

 

 

0 Likes
Accepted solutions (3)
2,384 Views
12 Replies
Replies (12)
Message 2 of 13

CADaSchtroumpf
Advisor
Advisor
Accepted solution

If you want you can try lisp BlockAtt2Vtx.

 

Commande: BLOCKATT2VTX

Sélectionner les Polylignes où placer un bloc avec attributs
Choix des objets: 1 trouvé(s) (select your polyline)

Choix des objets: (Enter for continue)

Incrementer en débutant à [chiffre/lettre/alphanumérique]: CH-000 (give the number or string)

162 blocs "Pointer" placés et renseignés.

Commande:

 

After this you can use:

 

Commande: _.QSELECT (and select block name "Pointer")
162 élément(s) sélectionné(s).

 

And in properties change the scale insertion X Y Z to 0.05 (for exemple)

Message 3 of 13

bit_Cad2018
Advocate
Advocate

thanks 

 

u r so amazing person

 

please only length text on my "CH" block wise not X,y,Z 

 

Please see my drawing 

 

0 Likes
Message 4 of 13

CADaSchtroumpf
Advisor
Advisor
Accepted solution

Ok

 

Specialy for your drawing, try this:

 

Be carrefull your drawing is reducted by a scale 0.5 ?? Isn't a good practice!

 

(defun c:BlockAtt2Vtx ( / js lst_posatt n nb_e ent dxf_ent dxf_210 lst_pt lst_dist lst_num vlaobj perim_obj pr pt abs_curv nb nb_dec inc d nbs ang pos_att)
  (cond
    ((eq (getvar "cvport") 1)
      (princ "\n** Command only allowed in Model Space.")
    )
    (T
      (if (not (tblsearch "STYLE" "RS"))
        (entmake
          '(
          (0 . "STYLE")
          (100 . "AcDbSymbolTableRecord")
          (100 . "AcDbTextStyleTableRecord")
          (2 . "RS")
          (70 . 0)
          (40 . 2.5)
          (41 . 0.8)
          (50 . 0.0)
          (71 . 0)
          (42 . 2.5)
          (3 . "romans.shx")
          (4 . "")
          )
        )
      )
;     (setvar "DIMASZ" 1.8)
      (if (not (tblsearch "BLOCK" "CH"))
        (progn
          (entmake
            '((0 . "BLOCK") (2 . "CH") (70 . 2) (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2) (10 0.0 0.0 0.0))
          )
          (entmake
            '(
              (0 . "LEADER")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "CH")
              (100 . "AcDbLeader")
              (3 . "Standard")
              (71 . 1)
              (72 . 0)
              (73 . 3)
              (74 . 1)
              (75 . 0)
              (40 . 0.0)
              (41 . 0.0)
              (76 . 2)
              (10 0.0 0.0 0.0)
              (10 -6.61668 -0.00308439 0.0)
              (211 1.0 0.000466154 0.0)
              (210 0.0 0.0 1.0)
              (212 0.0 0.0 0.0)
              (213 0.0 0.0 0.0)
            )
          )
          (entmake
            '(
              (0 . "ATTDEF")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "CH")
              (100 . "AcDbText")
              (10 -4.1139 0.230518 0.0)
              (40 . 0.9)
              (1 . "CH-0")
              (50 . 0.0)
              (41 . 0.8)
              (51 . 0.0)
              (7 . "RS")
              (71 . 0)
              (72 . 2)
              (11 -2.33105 0.680518 0.0)
              (210 0.0 0.0 1.0)
              (100 . "AcDbAttributeDefinition")
              (280 . 0)
              (3 . "")
              (2 . "TAG")
              (70 . 0)
              (73 . 0)
              (74 . 2)
              (280 . 1)
            )
          )
          (entmake '((0 . "ENDBLK") (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2)))
        )
      )
      (princ "\nSelect Polylines where put leader with attribut")
      (setq js (ssget '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 112) (-4 . "NOT>"))))
      (cond
        (js
          (setq lst_posatt '((-4.6620 1.3610 0.0)))
          (repeat (setq n (sslength js))
            (setq dxf_ent (entget (setq ent (ssname js (setq n (1- n))))) dxf_210 (cdr (assoc 210 dxf_ent)) lst_pt nil lst_dist nil)
            (setq
              vlaobj (vlax-ename->vla-object ent)
              perim_obj (vlax-curve-getDistAtParam vlaobj (vlax-curve-getEndParam vlaobj))
              pr -1
            )
            (repeat (setq nb_e (if (zerop (vlax-get vlaobj 'Closed)) (1+ (fix (vlax-curve-getEndParam vlaobj))) (fix (vlax-curve-getEndParam vlaobj))))
              (setq
                pt (vlax-curve-GetPointAtParam vlaobj (setq pr (1+ pr)))
                lst_pt (cons pt lst_pt)
                abs_curv (vlax-curve-getDistAtPoint vlaobj (vlax-curve-getClosestPointTo vlaobj (trans pt 1 0)))
                lst_dist (cons abs_curv lst_dist)
              )
            )
            (setq nbs (1- (length lst_pt)))
            (foreach pto lst_pt
              (setq
                d (car lst_dist)
                pos_att (mapcar '(lambda (x) (polar (trans '(0.0 0.0 0.0) dxf_210 0) (+ (angle (trans '(0.0 0.0 0.0) dxf_210 0) (trans x dxf_210 0)) 4.712388980384690) (distance (trans '(0.0 0.0 0.0) dxf_210 0) (trans x dxf_210 0)))) lst_posatt)
                nbs (1- nbs)
              )
              (entmake
                (append
                  '(
                    (0 . "INSERT")
                    (100 . "AcDbEntity")
                    (67 . 0)
                    (410 . "Model")
                    (8 . "CH")
                    (100 . "AcDbBlockReference")
                    (66 . 1)
                    (2 . "CH")
                    (41 . 2.0)
                    (42 . 2.0)
                    (43 . 2.0)
                    (50 . 4.712388980384690)
                    (70 . 0)
                    (71 . 0)
                    (44 . 0.0)
                    (45 . 0.0)
                  )
                  (list (cons 10 (trans pto 0 dxf_210)) (cons 210 dxf_210))
                )
              )
              (entmake
                (append
                  '(
                  (0 . "ATTRIB")
                  (100 . "AcDbEntity")
                  (67 . 0)
                  (410 . "Model")
                  (8 . "CH")
                  (100 . "AcDbText")
                  (50 . 4.712388980384690)
                  )
                  (list
                    (cons 10 (trans (list (+ (car pto) (caar pos_att)) (+ (cadr pto) (cadar pos_att)) (+ (caddr pto) (caddar pos_att))) 0 dxf_210))
                    (cons 1 (strcat "CH-" (rtos (* d 0.5) 2 0)))
                  )
                  '(
                  (40 . 1.8)
                  (41 . 0.8)
                  (51 . 0.0)
                  (7 . "RS")
                  (71 . 0)
                  (72 . 2)
                  )
                  (list
                    (cons 11 (trans (list (+ (car pto) (caar pos_att)) (+ (cadr pto) (cadar pos_att)) (+ (caddr pto) (caddar pos_att))) 0 dxf_210))
                    (cons 210 dxf_210)
                  )
                  '(
                  (100 . "AcDbAttribute")
                  (2 . "TAG")
                  (70 . 0)
                  (73 . 0)
                  (74 . 2)
                  )
                )
              )
              (entmake '((0 . "SEQEND") (62 . 256) (6 . "ByLayer") (370 . -2)))
              (setq lst_dist (cdr lst_dist))
            )
            (princ (strcat "\n" (itoa nb_e) " bloks \"CH\" have taking place."))
          )
        )
        (T (princ "\nSelection invalid or empty."))
      )
    )
  )
  (prin1)
)
Message 5 of 13

bit_Cad2018
Advocate
Advocate

only point number genrate sorry sir i trouble you

0 Likes
Message 6 of 13

bit_Cad2018
Advocate
Advocate

Please find Attachment

0 Likes
Message 7 of 13

bit_Cad2018
Advocate
Advocate

thanks sir 

0 Likes
Message 8 of 13

CADaSchtroumpf
Advisor
Advisor
Accepted solution

I have make the lisp with "DRAWIN.DWG", this have scale 1/2.

For file "CHAINAGE REQUIRE ALL CIRCLE POINT ALONG PIPELINE-1.DWG", use this:

 

Before use lisp; erase inserts of block "CH" and purge it.

 

(defun c:BlockAtt2Vtx ( / js lst_posatt n nb_e ent dxf_ent dxf_210 lst_pt lst_dist lst_num vlaobj perim_obj pr pt abs_curv nb nb_dec inc d nbs ang pos_att)
  (cond
    ((eq (getvar "cvport") 1)
      (princ "\n** Command only allowed in Model Space.")
    )
    (T
      (if (not (tblsearch "STYLE" "RS"))
        (entmake
          '(
          (0 . "STYLE")
          (100 . "AcDbSymbolTableRecord")
          (100 . "AcDbTextStyleTableRecord")
          (2 . "RS")
          (70 . 0)
          (40 . 2.5)
          (41 . 0.8)
          (50 . 0.0)
          (71 . 0)
          (42 . 2.5)
          (3 . "romans.shx")
          (4 . "")
          )
        )
      )
     (setvar "DIMASZ" 1.8)
      (if (not (tblsearch "BLOCK" "CH"))
        (progn
          (entmake
            '((0 . "BLOCK") (2 . "CH") (70 . 2) (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2) (10 0.0 0.0 0.0))
          )
          (entmake
            '(
              (0 . "LEADER")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "CH")
              (100 . "AcDbLeader")
              (3 . "Standard")
              (71 . 1)
              (72 . 0)
              (73 . 3)
              (74 . 1)
              (75 . 0)
              (40 . 0.0)
              (41 . 0.0)
              (76 . 2)
              (10 0.0 0.0 0.0)
              (10 6.61668 0.00308439 0.0)
              (211 1.0 0.000466154 0.0)
              (210 0.0 0.0 1.0)
              (212 0.0 0.0 0.0)
              (213 0.0 0.0 0.0)
            )
          )
          (entmake
            '(
              (0 . "ATTDEF")
              (100 . "AcDbEntity")
              (67 . 0)
              (410 . "Model")
              (8 . "CH")
              (100 . "AcDbText")
              (10 1.0 0.25 0.0)
              (40 . 0.9)
              (1 . "CH-0")
              (50 . 0.0)
              (41 . 0.8)
              (51 . 0.0)
              (7 . "RS")
              (71 . 0)
              (72 . 0)
              (11 1.0 0.7 0.0)
              (210 0.0 0.0 1.0)
              (100 . "AcDbAttributeDefinition")
              (280 . 0)
              (3 . "")
              (2 . "TAG")
              (70 . 0)
              (73 . 0)
              (74 . 2)
              (280 . 1)
            )
          )u 
          (entmake '((0 . "ENDBLK") (8 . "0") (62 . 256) (6 . "ByLayer") (370 . -2)))
        )
      )
      (princ "\nSelect Polylines where put leader with attribut")
      (setq js (ssget '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 112) (-4 . "NOT>"))))
      (cond
        (js
          (setq lst_posatt '((-1.4 3.0 0.0)))
          (repeat (setq n (sslength js))
            (setq dxf_ent (entget (setq ent (ssname js (setq n (1- n))))) dxf_210 (cdr (assoc 210 dxf_ent)) lst_pt nil lst_dist nil)
            (setq
              vlaobj (vlax-ename->vla-object ent)
              perim_obj (vlax-curve-getDistAtParam vlaobj (vlax-curve-getEndParam vlaobj))
              pr -1
            )
            (repeat (setq nb_e (if (zerop (vlax-get vlaobj 'Closed)) (1+ (fix (vlax-curve-getEndParam vlaobj))) (fix (vlax-curve-getEndParam vlaobj))))
              (setq
                pt (vlax-curve-GetPointAtParam vlaobj (setq pr (1+ pr)))
                lst_pt (cons pt lst_pt)
                abs_curv (vlax-curve-getDistAtPoint vlaobj (vlax-curve-getClosestPointTo vlaobj (trans pt 1 0)))
                lst_dist (cons abs_curv lst_dist)
              )
            )
            (setq nbs (1- (length lst_pt)))
            (foreach pto lst_pt
              (setq
                d (car lst_dist)
                pos_att (mapcar '(lambda (x) (polar (trans '(0.0 0.0 0.0) dxf_210 0) (+ (angle (trans '(0.0 0.0 0.0) dxf_210 0) (trans x dxf_210 0)) 4.712388980384690) (distance (trans '(0.0 0.0 0.0) dxf_210 0) (trans x dxf_210 0)))) lst_posatt)
                nbs (1- nbs)
              )
              (entmake
                (append
                  '(
                    (0 . "INSERT")
                    (100 . "AcDbEntity")
                    (67 . 0)
                    (410 . "Model")
                    (8 . "CH")
                    (100 . "AcDbBlockReference")
                    (66 . 1)
                    (2 . "CH")
                    (41 . 2.0)
                    (42 . 2.0)
                    (43 . 2.0)
                    (50 . 0.0)
                    (70 . 0)
                    (71 . 0)
                    (44 . 0.0)
                    (45 . 0.0)
                  )
                  (list (cons 10 (trans pto 0 dxf_210)) (cons 210 dxf_210))
                )
              )
              (entmake
                (append
                  '(
                  (0 . "ATTRIB")
                  (100 . "AcDbEntity")
                  (67 . 0)
                  (410 . "Model")
                  (8 . "CH")
                  (100 . "AcDbText")
                  (50 . 0.0)
                  )
                  (list
                    (cons 10 (trans (list (+ (car pto) (caar pos_att)) (+ (cadr pto) (cadar pos_att)) (+ (caddr pto) (caddar pos_att))) 0 dxf_210))
                    (cons 1 (strcat "CH-" (rtos d 2 0)))
                  )
                  '(
                  (40 . 1.8)
                  (41 . 0.8)
                  (51 . 0.0)
                  (7 . "RS")
                  (71 . 0)
                  (72 . 0)
                  )
                  (list
                    (cons 11 (trans (list (+ (car pto) (caar pos_att)) (+ (cadr pto) (cadar pos_att)) (+ (caddr pto) (caddar pos_att))) 0 dxf_210))
                    (cons 210 dxf_210)
                  )
                  '(
                  (100 . "AcDbAttribute")
                  (2 . "TAG")
                  (70 . 0)
                  (73 . 0)
                  (74 . 2)
                  )
                )
              )
              (entmake '((0 . "SEQEND") (62 . 256) (6 . "ByLayer") (370 . -2)))
              (setq lst_dist (cdr lst_dist))
            )
            (princ (strcat "\n" (itoa nb_e) " bloks \"CH\" have taking place."))
          )
        )
        (T (princ "\nSelection invalid or empty."))
      )
    )
  )
  (prin1)
)
Message 9 of 13

bit_Cad2018
Advocate
Advocate

Thank you very much for your help.

0 Likes
Message 10 of 13

bilal
Observer
Observer

 

hi..

can u add precision on chainage please ?  

eg : 10+000.25 ,10+500.80 (Need chainage like this. pls help)

0 Likes
Message 11 of 13

Kent1Cooper
Consultant
Consultant

@bilal wrote:

.... can u add precision on chainage please ?  

eg : 10+000.25 ,10+500.80 (Need chainage like this. pls help)


For the decimal places, change this line:

(cons 1 (strcat "CH-" (rtos d 2 0)))

to this:

(cons 1 (strcat "CH-" (rtos d 2 2)))

 Set the DIMZIN System Variable to something less than 8 [read about it in Help] to keep any trailing zeroes.

 

For the + separator, Search for routines in the Forums to insert that -- I'm sure there is something available.

Kent Cooper, AIA
0 Likes
Message 12 of 13

bilal
Observer
Observer

Wow.. thanks allot Mr.Kent1Cooper 🙏

0 Likes
Message 13 of 13

bilal
Observer
Observer

Hi Mr. Kent,

sorry to disturb you again. 

is there any chance to add '+' symbol on chainage ? (0+000 format)

and one more humble request that, have you any idea to label angle at deflection segments along poly line ?

let me attach a sample drawing for your ready reference.

thanks.

0 Likes