breaks selected line

Discussion in 'AutoCAD' started by chadidjaja, Aug 19, 2004.

  1. chadidjaja

    chadidjaja Guest

    Good day!

    I'm looking for a routine that will select a line, then that line will be broken at points where it intersect other lines.
    Or better, to draw a line which will break when intersect with other lines.

    Though I've found a few codes that can be modified, I'm not familiar with LISP. Any help will be much appreciated. Thanks!
     
    chadidjaja, Aug 19, 2004
    #1
  2. chadidjaja

    Jeff Mishler Guest

    Here's one that will allow you to select the line to break and the lines
    with which to break it. To change the "gap", change the line (setq gap 1.5)
    to whatever number you desire.
    Code:
    ;| Original posted to autodesk.customization newsgroup by
    SMMASON on 4/02/03....modified for specific task by
    Jeff Mishler on 8/04/03
    |;
    
    (defun c:brkint (/ BRK-PT1 BRK-PT2 GAP GAP1A INT-LIN1
    INT-LIN1A INT-LIN2A INT-PT1 INT-PT2
    INT-PT3 INT-PT4 INT-PT5 NUMLIN OLD-AUNITS
    OLD-LUNITS OLD-OSNAP OLD_ERROR ONSEG PICKTYPE PT1 PT2)
    (SETVAR "CMDECHO" 0)
    (setq old-osnap (getvar "osmode"))
    (setq old-lunits (getvar "lunits"))
    (setq old-aunits (getvar "aunits"))
    (setvar "osmode" 0)
    (setvar "lunits" 2)
    (setvar "aunits" 0)
    (setq old_error *error*)
    (defun *error* (msg)
    (if (not
    (member
    msg
    '("console break" "Function cancelled" "quit / exit abort")
    )
    )
    (progn
    (setvar "osmode" old-osnap)
    (setvar "lunits" old-lunits)
    (setvar "aunits" old-aunits)
    (redraw (car int-lin1) 4)
    (SETVAR "CMDECHO" 1)
    )
    )
    )
    
    ;;;(setq gap2 (if (= gap nil) 0.125 gap))
    ;;;(setq gap (getreal (strcat "\nEnter Break Gap Distance " "<" (rtos gap2)
    ">" ": ")))
    ;;;(if (= gap nil) (setq gap gap2))
    (setq gap 1.5)
    (setq gap1a (/ gap 2))
    
    (setq int-lin1 (entsel "\nSelect the Line to use as the Cutting Line: "))
    (redraw (car int-lin1) 3)
    (setq int-lin1a (entget (car int-lin1)))
    (setq int-pt1 (cdr (assoc 10 int-lin1a)))
    (setq int-pt2 (cdr (assoc 11 int-lin1a)))
    
    (initget 1 "F P")
    (setq picktype (getkword "\nUse Fence or Pick Lines to Break? <F or P>: "))
    (if (= picktype "F")
    (progn
    (setq pt1 (getpoint "\nLines to Break -> Pick First Fence Point: "))
    (setq pt2 (getpoint pt1 "\nPick Second Fence Point: "))
    (setq fence-cut (ssget "F" (list pt1 pt2) '((0 . "LINE")) ))
    (setq numlin 0)
    (while (<= numlin (- (sslength fence-cut) 1))
    (setq int-lin2 (entget (ssname fence-cut numlin)))
    (setq int-pt3 (cdr (assoc 10 int-lin2)))
    (setq int-pt4 (cdr (assoc 11 int-lin2)))
    (setq int-pt5 (inters int-pt1 int-pt2 int-pt3 int-pt4 onseg))
    (setq brk-pt1 (polar int-pt5 (angle int-pt5 int-pt3) gap1a))
    (setq brk-pt2 (polar int-pt5 (angle int-pt5 int-pt4) gap1a))
    (command "break" (ssname fence-cut numlin) brk-pt1 brk-pt2)
    (setq numlin (+ numlin 1))
    );end while
    );end progn
    (progn
    (while ;(= int-lin2 nil)
    (setq int-lin2 (entsel "\nSelect Line to Break: "))
    (setq int-lin2a (entget (car int-lin2)))
    (setq int-pt3 (cdr (assoc 10 int-lin2a)))
    (setq int-pt4 (cdr (assoc 11 int-lin2a)))
    (setq int-pt5 (inters int-pt1 int-pt2 int-pt3 int-pt4 onseg))
    (setq brk-pt1 (polar int-pt5 (angle int-pt5 int-pt3) gap1a))
    (setq brk-pt2 (polar int-pt5 (angle int-pt5 int-pt4) gap1a))
    (command "break" int-lin2 "f" brk-pt1 brk-pt2)
    ;(setq int-lin2 nil)
    );end while
    );end progn
    );end if
    
    (setvar "osmode" old-osnap)
    (setvar "lunits" old-lunits)
    (setvar "aunits" old-aunits)
    (redraw (car int-lin1) 4)
    (setq *error* old_error)
    (SETVAR "CMDECHO" 1)
    (princ)
    )
    

    --
    Jeff
    check out www.cadvault.com
    broken at points where it intersect other lines.
    LISP. Any help will be much appreciated. Thanks!
     
    Jeff Mishler, Aug 19, 2004
    #2
  3. chadidjaja

    chadidjaja Guest

    Hi Jeff, thanks a lot!
    With gap = 0.0, this is really close to what I need.

    The routine allows me to select a cutting line, then the lines to be broken; while I'm needing one that allows me to select which line to be broken, then the selected line will be cut by all intersecting lines on the same layer.
     
    chadidjaja, Aug 20, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.