Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BREAK LINES HORIZONTALLY OR VERTICALLY

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
kameron1967
4232 Views, 26 Replies

BREAK LINES HORIZONTALLY OR VERTICALLY

Just wondering if anyone can help me with a routine that has the option to break vertical or break horizontal, depending on the option, the lines that cross either the horizontal or vertical (again, depending on the option) a specified distance (say .05) on either side of the line you wanted to keep.  So if I choose BREAKH, the vertical lines that I choose would break any horizontal lines that cross them.  Same applies to BREAKV.  Hopefully I communicated clearly enough.  Thanks in advance!

26 REPLIES 26
Message 21 of 27
kameron1967
in reply to: alanjt_

Thanks, Alanjt_! You guys are awesome! I tested an earlier version and it didn't work. But the one on the link worked like a charm!  Thanks again, everyone!! LOL

Message 22 of 27
alanjt_
in reply to: kameron1967

Glad you got what you needed. 

Happy CADing.

Message 23 of 27
pbejse
in reply to: kameron1967

A mediocre code:

 

(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)
      )
    )
  )
)

 

 Only works for LINES and 1 segment polyline though.

 

Message 24 of 27
kameron1967
in reply to: pbejse

Pbejse - hi. Yes, this one trims horizontal lines around vertical ones. So it's got its usage for BREAKH command.

I then tried selecting only the horizontal lines and voila! - it now trims the vertical lines around the horizontal ones, thus meeting the BREAKV request.  Awesome.  Thank you very much, Pbejse! 

Message 25 of 27
pbejse
in reply to: kameron1967


@kameron1967 wrote:

....Thank you very much, Pbejse! 


You are welcome. Glad you found a use for the code kameron1967.

 

Cheers

Message 26 of 27
kameron1967
in reply to: pbejse

There are 3 different solutions, each with its own merit. I chose yours because it did what I needed it to do. That, however, should not reflect badly on the other solutions because they too have their own function and will offer solution to the limitation that your routine has when dealing with other entities. So I'm greatful for all who stepped up on this. It's one big happy family! Cheers! 🙂
Message 27 of 27
ank_josh
in reply to: kameron1967

how do i select for vertica lines?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost