Add Vertices to selected polylines at intersecting points with other polylines

Add Vertices to selected polylines at intersecting points with other polylines

Anonymous
Not applicable
3,195 Views
7 Replies
Message 1 of 8

Add Vertices to selected polylines at intersecting points with other polylines

Anonymous
Not applicable

 Hi everyone;

I am looking to find a lisp command to automatically create vertices at intersecting polylines. In fact, the two polylines are overlapped and each of the at a different layer. As in the pics.

I am looking for a straight forward way where I can do it to all polylines of similar properties (for example, adding vertices to all polylines in white color at intersecting point with yellow lines).

I have searched and tried many commands I found but none of them was successful in my case>

 

Your help is highly appreciated..

 

Thanks in advance ^^

0 Likes
3,196 Views
7 Replies
Replies (7)
Message 2 of 8

CADaSchtroumpf
Advisor
Advisor

Hi,

 

This can help you?

 

(vl-load-com)
(defun add_vtx (obj add_pt ent_name / bulg)
  (vla-addVertex
    obj
    (1+ (fix add_pt))
    (vlax-make-variant
      (vlax-safearray-fill
        (vlax-make-safearray vlax-vbdouble (cons 0 1))
          (list
            (car (trans (vlax-curve-getpointatparam obj add_pt) 0 ent_name))
            (cadr (trans (vlax-curve-getpointatparam obj add_pt) 0 ent_name))
          )
      )
    )
  )
  (setq bulg (vla-GetBulge obj (fix add_pt)))
  (vla-SetBulge obj
    (fix add_pt)
    (/
      (sin (/ (* 4 (atan bulg) (- add_pt (fix add_pt))) 4))
      (cos (/ (* 4 (atan bulg) (- add_pt (fix add_pt))) 4))
    )
  )
  (vla-SetBulge obj
    (1+ (fix add_pt))
    (/
      (sin (/ (* 4 (atan bulg) (- (1+ (fix add_pt)) add_pt)) 4))
      (cos (/ (* 4 (atan bulg) (- (1+ (fix add_pt)) add_pt)) 4))
    )
  )
  (vla-update obj)
)
(defun c:add_vertexAtInt ( / lst_pt js e_name obj js_b nb tmp_name tmp_obj vrt_pt pt)
  (princ "\nSelect POLYLINE")
  (while (null (setq js (ssget "_+.:E:S" '((0 . "LWPOLYLINE")))))
    (princ "\nIsn't an object available!")
  )
  (setq obj (vlax-ename->vla-object (setq e_name (ssname js 0))))
  (princ "\nSelect cutting objects")
  (setq js_b (ssget))
  (repeat (setq nb (sslength js_b))
    (setq tmp_name (ssname js_b (setq nb (1- nb))))
    (cond
      (tmp_name
        (setq
          tmp_obj (vlax-ename->vla-object tmp_name)
          vrt_pt (vlax-variant-value (vla-IntersectWith obj tmp_obj 0))
        )
        (if (>= (vlax-safearray-get-u-bound vrt_pt 1) 0)
          (progn
            (setq pt (vlax-safearray->list vrt_pt))
            (if pt
              (if (> (length pt) 3)
                (repeat (/ (length pt) 3)
                  (setq lst_pt (cons (list (car pt) (cadr pt) (caddr pt)) lst_pt) pt (cdddr pt))
                )
                (setq lst_pt (cons pt lst_pt))
              )
            )
          )
        )
      )
    )
  )
  (if (and lst_pt (listp lst_pt))
    (foreach el lst_pt
      (add_vtx obj (vlax-curve-getparamatpoint obj (vlax-curve-getClosestPointTo obj (trans el 1 0))) e_name)
    )
  )
  (prin1)
)
0 Likes
Message 3 of 8

Anonymous
Not applicable

Thank you but unfortunately it did not work as expected 😕 it is causing the whole shape to move as in this pic

0 Likes
Message 4 of 8

marko_ribar
Advisor
Advisor

Try "plintav.lsp" or "plintav-new.lsp" from PLINE TOOLOS posted here :

 

http://www.cadtutor.net/forum/showthread.php?67924-Draw-polyline-along-with-2-or-more-adjacent-close...

 

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 5 of 8

Anonymous
Not applicable

Thank you sooo much! This is exactly what I am looking for.. THANK YOU!

0 Likes
Message 6 of 8

marko_ribar
Advisor
Advisor

I didn't get neither kudo nor solution... 😞

 

BTW. If you have self-intersecting LWPOLYLINE, to get intersecting vertices, you'll have to make copy of it at the same place and apply routine on selection set of those 2 entities (LWPOLYLINES)... Then you remove copy - one of them and result is left one but now with intersecting vertices...

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 7 of 8

jtm2020hyo
Collaborator
Collaborator

imagen.png

 

 

link does not exist.

0 Likes
Message 8 of 8

marko_ribar
Advisor
Advisor