Break multiple polylines with each other

Break multiple polylines with each other

eng_mohamedmustafa
Enthusiast Enthusiast
5,024 Views
40 Replies
Message 1 of 41

Break multiple polylines with each other

eng_mohamedmustafa
Enthusiast
Enthusiast

Hi >>> please help me in this .... after some search on the forum i find this lisp (break lines, polylines) for entire drawing.

 

 

(defun c:bmcut (/ _pts d cutter e pts pts2 p1 p2)
  (defun _pts (ent)
    (mapcar 'cdr (vl-remove-if-not '(lambda (x)
		(member (car x) '(10 11))) ent)))                       
  (setq d (getdist "\nEnter Gap distance: "))
  (princ "\nSelect Cutter lines:")
  (setq cutter (ssget (setq fl '((-4 . "<OR")
                        (-4 . "<AND")
                        (0 . "LWPOLYLINE")
                        (90 . 2)
                        (-4 . "AND>")
                        (0 . "LINE")
                        (-4 . "OR>")
                       ))
               )
  )
  (repeat (setq i (sslength cutter))
    (setq e (ssname cutter (setq i (1- i))))
    (setq pts (_pts (entget e)))
    (if (and (setq cut-ee (ssget "_F" pts fl))
             (ssdel e cut-ee)
        )
      (repeat (setq n (sslength cut-ee))
        (Setq en (ssname cut-ee (setq n (1- n))))
        (setq pts2 (_pts (entget en)))
        (setq bpt (inters (Car pts) (cadr pts) (car pts2) (cadr pts2)))
        (setq p1 (polar bpt (angle (car pts2) (cadr pts2)) (* d 0.5)))
        (setq p2 (polar bpt (angle (cadr pts2) (car pts2)) (* d 0.5)))
        (command "_break" en "_non" p1 "_non" p2)
      )
    )
  )
)

 

 

but i want some edits please >>>

1- this lisp for only vertical and horizontal poly lines only +++ ... that means if i have polyline path with (s) shape for example the lisp ignore to select the path so i want the lisp to select any shape of polyline routing

2- if i have huge drawing with multiple polylines routing i want to select entire drawing and set my gap ... then the lisp compare between the no. of polylines of the intersecting polylines and the greater the no. of polylines will cut and break the fewer the no. of polylines that intersecting with them with my specific gap

3- (optional) i want to insert spline or brackets at breaked polylines

thanks and hope to help

0 Likes
5,025 Views
40 Replies
Replies (40)
Message 2 of 41

john.uhden
Mentor
Mentor

@eng_mohamedmustafa 

To get all the intersections you will probably have to use the vla-intersectwith method.

I'm not seeing how you would differentiate the "larger number" from the "smaller number."

Plus, after breaking one object at another, the broken pieces could still intersect with others and need further breaking.  I trust that all the lines and polylines are at the same uniform elevation.

John F. Uhden

0 Likes
Message 3 of 41

devitg
Advisor
Advisor

@eng_mohamedmustafa , It seem to be , I had seen this topic at other forum. 

One option was to insert a block with wipepout at each intersection, so all polylines hold its values. 

 

0 Likes
Message 4 of 41

john.uhden
Mentor
Mentor

@devitg 

I think I like that wipeout approach, presuming he wants to really keep things attached.

But perhaps he is of Roman descent and prefers to divide and conquer.

John F. Uhden

0 Likes
Message 5 of 41

Sea-Haven
Mentor
Mentor

Like the speed bump in the road that is also an option for intersect lines.

 

Post a sample dwg.

0 Likes
Message 6 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

attached DWG sample

0 Likes
Message 7 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

anyone has proper solution for this ??? 🤔

0 Likes
Message 8 of 41

ВeekeeCZ
Consultant
Consultant

You know there IS a perfectly suitable solution, HERE  

Just that someone values his job so it's not for free.

0 Likes
Message 9 of 41

CADaSchtroumpf
Advisor
Advisor

A start with this.

You can replace point by insert a bloc with a wipeout in is defintion!

 

 

((lambda ( / lst_pt js n e_name obj js_b nb tmp_name tmp_obj vrt_pt pt)
  (vl-load-com)
  (setq js (ssget))
  (repeat (setq n (sslength js))
    (setq e_name (ssname js (setq n (1- n))))
    (cond
      (e_name
        (setq
          obj (vlax-ename->vla-object e_name)
          js_b (ssdel e_name js)
        )
        (repeat (setq nb (sslength js_b))
          (setq tmp_name (ssname js (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 (entmake (list (cons 0 "POINT") (cons 10 el))))
  )
  (prin1)
))

 

0 Likes
Message 10 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

@ВeekeeCZplease if you have solution post it >>> if not please ignore my post ... It's none of your business to judge whether I pay or not... I know what I'm doing

thanks

0 Likes
Message 11 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

i try this but the first issue my friend is to break all intersecting polylines ... then insert block ... can you see my attached DWG?? i mention the steps of lisp i need

best regards

0 Likes
Message 12 of 41

ronjonp
Mentor
Mentor

THIS does not insert the blocks at the ends but will break with a certain gap.

0 Likes
Message 13 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

dear sir ... the link not working

0 Likes
Message 14 of 41

Kent1Cooper
Consultant
Consultant

@eng_mohamedmustafa wrote:

....

1- this lisp for only vertical and horizontal poly lines only +++ ... that means if i have polyline path with (s) shape for example the lisp ignore to select the path so i want the lisp to select any shape of polyline routing

....


It does work with Lines/Polylines that are not vertical or horizontal:

Kent1Cooper_0-1669657937700.png

I suspect the problem in your case is not about the direction they run, but that the routine is designed to work with Lines and with Polylines of only one line segment.  It restricts the selection to those with only two vertices [the (90 . 2) part], which is the reason it refuses to accept selection of many of the Polylines in your sample drawing.  And its operation uses the straight-line direction between those two vertices, which means that with a Polyline of two vertices but consisting of only a single arc segment, the breaking will usually be in the wrong place.

 

I'm afraid what you want to do will involve far more than editing that routine.  The entire approach will need to be very different.  One of the big differences is that you have pairs of Polylines that intersect each other in more than one place, which complicates the operation.  Another is your desire to have things that cross multiple other things close together be broken only once, around the group of other things -- figuring out the multiple crossings in their groupings by proximity is another big challenge.

Kent Cooper, AIA
0 Likes
Message 15 of 41

CADaSchtroumpf
Advisor
Advisor

Or see QBrick of Kamal Boutora, it break all objects

0 Likes
Message 16 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

yes sir you are right about (90 . 2)  ... i try another lisp (attached) and i test it with command "BreakAll" but the lisp break all intersecting polylines (attached image) ... i want to select all but break one group of them and remain the other without breaking 

0 Likes
Message 17 of 41

eng_mohamedmustafa
Enthusiast
Enthusiast

this lisp break all ... the required to break one of them as per attached DWG

0 Likes
Message 18 of 41

Kent1Cooper
Consultant
Consultant

@CADaSchtroumpf wrote:

A start with this. ....


Somehow that doesn't find all intersections:

Kent1Cooper_0-1669662813753.png

But even if it did, and likewise with offerings that break everything with all intersections with everything else, it's a far cry from what they're looking for, with things broken once around a whole group of crossing things that are not broken:

Kent1Cooper_1-1669662891415.png  

Kent1Cooper_2-1669662935859.png

Not that I have a solution to offer, but suggestions should at least be aiming in the right direction.

Kent Cooper, AIA
0 Likes
Message 19 of 41

ronjonp
Mentor
Mentor

@eng_mohamedmustafa 

Maybe try 'BreakWith' instead.

ronjonp_0-1669663232844.png

 

0 Likes
Message 20 of 41

CADaSchtroumpf
Advisor
Advisor

@Kent1Cooper  a écrit :

@CADaSchtroumpf wrote:

A start with this. ....


Somehow that doesn't find all intersections:

Kent1Cooper_0-1669662813753.png

 


Oh yes I had not see it! You are right.

I have corrected the code

0 Likes