Jump to content

Cumulative distance at intersection


souvik

Recommended Posts

I need to assign a cumulative distance chainage at a polyline which have some intersections. The distance chainage should be in negative and positive from 0.00. I will pick the o.oo point and the other chainage will be denoted automatically. I'm attaching a image. Please help me in this matter.

Capture.png

Link to comment
Share on other sites

Try this draft and let me know .

 


(defun c:Test (/ _t s p pt st nd vl lst lft rgt en i ss ins)
 ;;    Tharwat 02.11.2014    ;;
 ;;                ;;
 (defun _t (p v)
   (entmakex (list '(0 . "TEXT")
                   (cons 10 (trans p 1 0))
                   (cons 11 (trans p 1 0))
                   (cons 1 v)
                   (cons 7 (getvar 'TEXTSTYLE))
                   (cons 40 (getvar 'TEXTSIZE))
                   '(50 . 1.5708)
                   '(71 . 0)
                   '(72 . 2)
                   '(73 . 0)
             )
   )
 )
 (princ "\n << Pick LwPolyline : >>")
 (if
   (and (setq s (ssget "_+.:S:E:L"
                       '((0 . "LWPOLYLINE")
                         (-4 . "<NOT")
                         (-4 . "<>")
                         (42 . 0.0)
                         (-4 . "NOT>")
                        )
                )
        )
        (setq
          p (getpoint "\n Specify Origin point on Selected LwPolyline :"
            )
        )
   )
    (progn
      (setq pt (vlax-curve-getclosestpointto (setq en (ssname s 0)) p)
            st (vlax-curve-getstartpoint en)
            nd (vlax-curve-getendpoint en)
            vl (vlax-ename->vla-object en)
      )
      (foreach x (entget en)
        (if (eq (car x) 10)
          (setq lst (cons (list (cadr x) (caddr x)) lst))
        )
      )
      (if (< (car st) (car nd))
        (setq lft st
              rgt nd
        )
        (setq lft nd
              rgt st
        )
      )
      (if (setq ss (ssget "_F" lst))
        (progn
          (if (ssmemb en ss)
            (ssdel en ss)
          )
          (repeat (setq i (sslength ss))
            (if (setq ins
                       (vlax-invoke
                         vl
                         'intersectwith
                         (vlax-ename->vla-object (ssname ss (setq i (1- i))))
                         acextendnone
                       )
                )
              (if (< (car ins) (car p))
                (_t ins (strcat "-" (rtos (car ins) 2)))
                (_t ins (rtos (car ins) 2))
              )
            )
          )
          (_t pt "0.0")
          (_t lft (strcat "-" (rtos (car lft) 2)))
          (_t rgt (rtos (car rgt) 2))
        )
      )
    )
 )
 (princ)
)(vl-load-com)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...