Break Line at Int.

Discussion in 'AutoCAD' started by Lee Ballou, Jun 21, 2004.

  1. Lee Ballou

    Lee Ballou Guest

    I found this LSP file to break a line at an intersection, but when i pick
    the line it will not highlight.
    Could someone tell me what I need to add to the LSP to make the picked line
    to highlight.

    ;breaks line at an intersection

    (defun c:bi ( / ss point snap echo olderr)
    (setq snap (getvar "osmode"))
    (setq echo (getvar "cmdecho"))
    (setq olderr *error*)
    (setq *error* break_error)
    (setvar "cmdecho" 0)
    (while (not ss)
    (setq ss (entsel "\nSelect line to break: "))
    );while
    (setvar "osmode" 32)
    (while (not point)
    (setq point
    (osnap (getpoint "\nSelect intersection to break at: ") "int"))
    );while
    (setvar "osmode" snap)
    (command "break" ss "f" point "@")
    (setvar "cmdecho" echo)
    (setq *error* olderr)
    (princ)
    )

    (defun break_error (msg)
    (princ (strcat "\nError: " msg))
    (setvar "osmode" 0)
    (setvar "cmdecho" 1)
    (princ)
    )

    Thanks
     
    Lee Ballou, Jun 21, 2004
    #1
  2. Lee Ballou

    Jürg Menzi Guest

    Hi Lee

    Add 'redraw':

    <snip>
    (while (not ss)
    (setq ss (entsel "\nSelect line to break: "))
    );while
    (redraw (car ss) 3)
    ...
    (command "break" ss "f" point "@")
    (redraw (car ss) 4)
    <snip>

    Cheers
     
    Jürg Menzi, Jun 21, 2004
    #2
  3. If you ask me, you're better off taking a whole lot AWAY from the lisp,
    rather than adding to it. This is one of those way-overkill routines, in my
    opinion. You could just do this:

    [BreakAtInt]^C^CBREAK \F INT \@

    or:

    (command "BREAK" pause "F" "INT" pause "@")

    It doesn't seem to have occurred to whoever wrote such a routine that if you
    have more local variables than you have steps in the entire process, maybe
    there's something wrong. Not to mention that if you're setting OSMODE to
    32, you don't need to spell out the "int" object-snap (or, if you're going
    to spell it out, you don't need to save the current value, set it, and reset
    it later). Not to mention that the prompt should say "Select object [or
    "entity", or "item", but not "line"] to break: ", since you might want to
    break an arc or a circle or a polyline or an xline or a ray or a <whatever
    else>, and the routine would certainly work for any of those, not just
    lines.

    Kent Cooper, AIA


    ...
     
    Kent Cooper, AIA, Jun 21, 2004
    #3
  4. Here is my shorter BI command

    ;BI = break line,polyline,arc at apparent intersection
    (defun C:BI (/ ES P1)
    (SAVELOO)
    (princ "\nBREAK Pline,Line,Arc at apparent Intersection")
    (setq ES (entsel "\nSelect Line to Break ? "))
    (while ES
    (setvar "OSMODE" 2048)
    (setq P1 (getpoint "\nPick <apparent> on Line to Break ? "))
    (setvar "OSMODE" 0)
    (if P1 (command "_BREAK" (cadr ES) "F" P1 P1))
    (setq ES (entsel "\nSelect Line to Break ? "))
    )
    (RESETLOO)
    (princ)
    )

    ;SAVELOO & RESETLOO to save variables
    ;--subroutine to save current layer, osmode, orthomode-------------------
    (defun SAVELOO ()
    (setvar "CMDECHO" 0)
    (setvar "BLIPMODE" 0)
    (setvar "EXPERT" 1)
    (setq CSV_LN (getvar "CLAYER"))
    (setq CSV_OS (getvar "OSMODE"))
    (setq CSV_OM (getvar "ORTHOMODE"))
    (setvar "OSMODE" 0)
    (setvar "ORTHOMODE" 0)
    )
    ;--subroutine to reset layer, osmode, orthomode--------------------------
    (defun RESETLOO ()
    (setvar "CLAYER" CSV_LN)
    (setvar "OSMODE" CSV_OS)
    (setvar "ORTHOMODE" CSV_OM)
    )
     
    Alan Henderson @ A'cad Solutions, Jun 21, 2004
    #4
  5. Lee Ballou

    ECCAD Guest

    (setvar "HIGHLIGHT" 1)

    Bob
     
    ECCAD, Jun 21, 2004
    #5
  6. Lee Ballou

    Lee Ballou Guest

    Thanks the redraw works.
     
    Lee Ballou, Jun 22, 2004
    #6
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.