Insert block on profile polyline from plan alignment vertexes by horizontal distance (Delta X)

Insert block on profile polyline from plan alignment vertexes by horizontal distance (Delta X)

neam
Collaborator Collaborator
660 Views
8 Replies
Message 1 of 9

Insert block on profile polyline from plan alignment vertexes by horizontal distance (Delta X)

neam
Collaborator
Collaborator

Hi everyone

I write two routines for specify profile pline vertexes to plan alignment. and plan alignment vertexes to profile pline.

but i want insert block from plan vertexes to profile by delta x distance on profile pline.

I would be grateful if you could guide me.

0 Likes
Accepted solutions (1)
661 Views
8 Replies
Replies (8)
Message 2 of 9

CADaSchtroumpf
Advisor
Advisor

Perhaps this? If I have understood...

((lambda ( / ss ent obj ll ur ss_txt n dxf_ent txt val pt)
  (vl-load-com)
  (setvar "CMDECHO" 0)
  (princ "\nSelect Plan Alignment : ")
  (while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (8 . "C-ROAD-CNTR-N") (62 . 6) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
  (setq
    ent (ssname ss 0)
    obj (vlax-ename->vla-object ent)
  )
  (vla-GetBoundingBox obj 'll 'ur)
  (setq
    ll (safearray-value ll)
    ur (safearray-value ur)
  )
  (command "_.zoom" "_w" ll ur)
  (setq ss_txt (ssget "_C" ll ur '((0 . "MTEXT"))))
  (cond
    (ss_txt
      (princ "\nSelect Profile Pline: ")
      (while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (62 . 4) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
      (setq ent (ssname ss 0))
      (repeat (setq n (sslength ss_txt))
        (setq
          dxf_ent (entget (ssname ss_txt (setq n (1- n))))
          txt (vl-string-left-trim "PVI\nKM.=" (cdr (assoc 1 dxf_ent)))
          val (atof (vl-string-subst "" "+" txt))
          pt (vlax-curve-getPointAtDist ent val)
        )
        (command "_.-insert" "Pick" "_none" pt "" "" "")
        (command "._text" "_none" pt "" "90" (strcat "PVI=" txt))
      )
    )
  )
  (setvar "CMDECHO" 1)
  (prin1)
))
Message 3 of 9

Sea-Haven
Mentor
Mentor

This is a tick button in other addon software a default style of answer and produces multiple sheets where required for long alignments. Look for company name in image.

 

SeaHaven_0-1683532010742.png

 

Message 4 of 9

neam
Collaborator
Collaborator

Hi dear cadaschtoumpf:

Thank you for your attention

I want the km of each vertex of the plan to be shown on the profile polyline.
This is possible when we introduce a straight polyline as a profile.
But when the profile polyline has multiple failures, the value of Delta X should be implemented on it.

(I apologize for my poor English.)

0 Likes
Message 5 of 9

neam
Collaborator
Collaborator

Hi dear sea-haven

This operation is easily possible in autocad civil 3d.
But I deal with AutoCAD objects in maps that are given to me by other people.

0 Likes
Message 6 of 9

CADaSchtroumpf
Advisor
Advisor

Not sure I understand, but try this...
For 'Profile Pline' do not select the straight cyan polyline but the one with many vertices. (contrary to the previous proposition)

 

 

((lambda ( / ss ent lg obj ll ur ss_txt k n dxf_ent txt val pt)
  (vl-load-com)
  (setvar "CMDECHO" 0)
  (princ "\nSelect Plan Alignment : ")
  (while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (8 . "C-ROAD-CNTR-N") (62 . 6) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
  (setq
    ent (ssname ss 0)
    lg (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
    obj (vlax-ename->vla-object ent)
  )
  (vla-GetBoundingBox obj 'll 'ur)
  (setq
    ll (safearray-value ll)
    ur (safearray-value ur)
  )
  (command "_.zoom" "_w" ll ur)
  (setq ss_txt (ssget "_C" ll ur '((0 . "MTEXT"))))
  (cond
    (ss_txt
      (princ "\nSelect Profile Pline: ")
      (while (not (setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (62 . 4) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
      (setq
        ent (ssname ss 0)
        k (/ (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent)) lg)
      )
      (repeat (setq n (sslength ss_txt))
        (setq
          dxf_ent (entget (ssname ss_txt (setq n (1- n))))
          txt (vl-string-left-trim "PVI\nKM.=" (cdr (assoc 1 dxf_ent)))
          val (atof (vl-string-subst "" "+" txt))
          lg (* k val)
          pt (vlax-curve-getPointAtDist ent lg)
        )
        (command "_.-insert" "Pick" "_none" pt "" "" "")
        (command "._text" "_none" pt "" "90" (strcat "PVI=" txt))
      )
    )
  )
  (setvar "CMDECHO" 1)
  (prin1)
))

 

0 Likes
Message 7 of 9

neam
Collaborator
Collaborator

Hi

I sent the sample file to clarify my question.

0 Likes
Message 8 of 9

CADaSchtroumpf
Advisor
Advisor
Accepted solution

OK, I think that I have understood.

((lambda ( / ss_pa ent_pa obj ll ur ss_bl AcDoc Space ss_pl obj_pl pt_ori n dxf_ent lg startPoint endPoint nw_line pt d1 d2 d3 d4 d5 txt e1 ee1)
  (vl-load-com)
  (setvar "CMDECHO" 0)
  (princ "\nSelect Plan Alignment : ")
  (while (not (setq ss_pa (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (8 . "C-ROAD-CNTR-N") (62 . 6) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
  (setq
    ent_pa (ssname ss_pa 0)
    obj (vlax-ename->vla-object ent_pa)
  )
  (vla-GetBoundingBox obj 'll 'ur)
  (setq
    ll (safearray-value ll)
    ur (safearray-value ur)
  )
  (command "_.zoom" "_w" ll ur)
  (setq ss_bl (ssget "_C" ll ur '((0 . "INSERT") (2 . "IP"))))
  (cond
    (ss_bl
      (setq
        AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
        Space
        (if (= 1 (getvar "CVPORT"))
          (vla-get-PaperSpace AcDoc)
          (vla-get-ModelSpace AcDoc)
        )
      )
      (princ "\nSelect Profile Pline: ")
      (while (not (setq ss_pl (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (67 . 0) (62 . 4) (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))))
      (setq
        obj_pl (vlax-ename->vla-object (ssname ss_pl 0))
        pt_ori (vlax-curve-getStartPoint obj_pl)
      )
      (repeat (setq n (sslength ss_bl))
        (setq
          dxf_ent (entget (ssname ss_bl (setq n (1- n))))
          lg (vlax-curve-GetDistAtPoint ent_pa (vlax-curve-getClosestPointTo ent_pa (cdr (assoc 10 dxf_ent)) nil))
          startPoint (vlax-3d-point (list (+ (car pt_ori) lg) (cadr pt_ori) (caddr pt_ori)))
          endPoint (vlax-3d-point (list (+ (car pt_ori) lg) (+ (cadr pt_ori) lg) (caddr pt_ori)))
          nw_line (vla-AddLine Space startPoint endPoint)
          pt (vlax-invoke obj_pl 'IntersectWith nw_line 3)
          d1 (substr (rtos lg 2 2) 2 1)
          d2 (substr (rtos lg 2 2) 3 1)
          d3 (substr (rtos lg 2 2) 4 1)
          d4 (substr (rtos lg 2 2) 5 1)
          d5 (substr (rtos lg 2 2) 6 1)
        )
        (if (= d1 ".")
          (setq txt (strcat "0+00" (rtos lg 2 2)))
        )
        (if (= d2 ".")
          (setq txt (strcat "0+0" (rtos lg 2 2)))
        )
        (if (= d3 ".")
          (setq txt (strcat "0+" (rtos lg 2 2)))
        )
        (if (= d4 ".")
          (setq
            e1 (substr (rtos lg 2 2) 1 1)
            ee1 (substr (rtos lg 2 2) 2 8)
            txt (strcat e1 "+" ee1)
          )
        )
        (if (= d5 ".")
          (setq
            e1 (substr (rtos lg 2 2) 1 1)
            e2 (substr (rtos lg 2 2) 1 2)
            ee1 (substr (rtos lg 2 2) 3 8)
            txt (strcat e2 "+" ee1)
          )
        )
        (entdel (entlast))
        (command "_.-insert" "Pick" "_none" pt "" "" "")
        (command "._text" "_none" pt "" "90" (strcat "PI=" txt))
      )
    )
  )
  (setvar "CMDECHO" 1)
  (prin1)
))

 

0 Likes
Message 9 of 9

neam
Collaborator
Collaborator

HI Dear CADaSchtroumpf:

Thank you very much for your time to solve my problem.

0 Likes