Overlap With Trimming Lines

Overlap With Trimming Lines

rpajounia
Advocate Advocate
303 Views
4 Replies
Message 1 of 5

Overlap With Trimming Lines

rpajounia
Advocate
Advocate

So i am currently using the code below and it creates a new line between overlapping lines but i also need to trim the over lapping lines too can someone help me modify it


Example:

Line one starts from 0 to 5

Line two starts from 3 to 8


Make line one 0 to 3

Makes new line 3 to 5

Make line two 5 to 8

 

 

(defun c:overlap ( / _line _online a e i l s ent ss1)

   (defun _line ( a b )
       (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
   )
   (defun _online ( p a b )
       (equal (+ (distance p a) (distance p b)) (distance a b) 1e-1)
   )            
   (if (setq s (ssget "_A" '((0 . "LINE"))))
       (progn
           (repeat (setq i (sslength s))
               (setq e (entget (ssname s (setq i (1- i))))
                     l (cons (list (cdr (assoc 10 e)) (cdr (assoc 11 e))) l)
               )
           )
           (while (setq a (car l))
               (foreach b (setq l (cdr l))
		   (princ l)
                   (cond
                       (   (or
                               (and
                                   (equal (car  a) (car  b) 1e-1)
                                   (equal (cadr a) (cadr b) 1e-1)
                               )
                               (and
                                   (equal (car  a) (cadr b) 1e-1)
                                   (equal (cadr a) (car  b) 1e-1)
                               )
                           )
                           (apply '_line a)
                       )
                       (   (and
                               (_online (car a) (car b) (cadr b))
                               (_online (car b) (car a) (cadr a))
                               (not (equal (car a) (car b) 1e-1))
                           )
                           (_line (car a) (car b))
                       )
                       (   (and
                               (_online (car  a) (car b) (cadr b))
                               (_online (cadr b) (car a) (cadr a))
                               (not (equal (car a) (cadr b) 1e-1))
                           )
                           (_line (car a) (cadr b))
                       )
                       (   (and
                               (_online (cadr a) (car b) (cadr b))
                               (_online (car  b) (car a) (cadr a))
                               (not (equal (cadr a) (car b) 1e-1))
                           )
                           (_line (cadr a) (car b))
                       )
                       (   (and
                               (_online (cadr a) (car b) (cadr b))
                               (_online (cadr b) (car a) (cadr a))
                               (not (equal (cadr a) (cadr b) 1e-1))
                           )
                           (_line (cadr a) (cadr b))
                       )
                   )
               )
           )
       )
   )
   (princ)
)

 

0 Likes
304 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Post a drawing to illustrate what it does and what you would like to have.

0 Likes
Message 3 of 5

Kent1Cooper
Consultant
Consultant

I understand what you're after without a sample drawing, but I have a question:

 

The first condition is for when two Lines coincide completely [both endpoints the same within tolerance, whether drawn in the same or opposite directions].  In that case, it draws a third Line that also coincides with both [presumably you are in a Layer devoted to the overlap Lines, to distinguish].  Given your description, would you instead want to simply remove one of them?

EDIT:  And a second question:  When two Lines share one end, I assume you would want to leave the shorter one and shorten the longer one [take its end that coincides to the other end of the shorter Line].  So you would have just two Lines as a result.  Is that correct?

Kent Cooper, AIA
0 Likes
Message 4 of 5

Sea-Haven
Mentor
Mentor

I may be reading incorrect is it break longer line making 2 and erase shorter line. 

0 Likes
Message 5 of 5

rpajounia
Advocate
Advocate

I was actually able to make it work with the overkill function thank you for the attempt in help

0 Likes