"Unbreak" command

Discussion in 'AutoCAD' started by pthomas3, Aug 7, 2003.

  1. pthomas3

    pthomas3 Guest

    Is there a command in AutoCAD 2002, that allows you to mend a broken line, arc, whatever?
    I've just been using the extend or fillet commands, but it just seems that there should be a simple command that fills in a gap when you delete and intersecting entity.
    Thanks!
     
    pthomas3, Aug 7, 2003
    #1
  2. pthomas3

    Jamie Duncan Guest

    I use glue:



     



    ;;;  Glue.lsp
    ;;;--------------------------------------------------------------------------
    ;;;  DESCRIPTION
    ;;;
    ;;;  This routine joins two separate line entities into one line.
    ;;;
    ;;;--------------------------------------------------------------------------
    (defun c:arctglue (/ ent1 ent2 lin1ps lin1pt1 linpt2 lin2ps lin2pt1 lin2pt2 dis1
                 dis2 dis3 dis4 dislist maxdis pts pt1 pt2 gluerr)
      ;;;(arctvsav)
      (defun gluerr (st)                  ; Internal error handler
        (if (or (/= st "Function cancelled")(= st "quit / exit abort"))
          (princ)
          (princ (strcat "\nError: " st))
        )
       ;;; (arctvrst)
        (princ)
      )
      (setvar "cmdecho" 0)
      (setvar "osmode" 0)
      (setq *error* gluerr)



     



      ;;----------Program Start-----------------------------------------------
      (setq ent1 (entsel "\nSelect first line: "))
      ;; Pick the two lines and show them
      (while ent1
        (redraw (setq ent1 (car ent1)) 3)
        (while (or (null (setq ent2 (entsel "\nSelect second line: ")))
                   (if ent2 (equal (car ent2) ent1))
               )
        )
        (redraw (setq ent2 (car ent2)) 3)
        ;; Trap out any selected entities that are not LINE entities
        (while (or (/= "LINE" (cdr (assoc 0 (entget ent1))))
                   (/= "LINE" (cdr (assoc 0 (entget ent2))))
               )
          (redraw ent1)(redraw ent2)
          (prompt "\nThe entities selected are not LINE entities.")
          (while (null (setq ent1 (entsel "\nSelect first line: "))))
          (redraw (setq ent1 (car ent1)) 3)
          (while (null (setq ent2 (entsel "\nSelect second line: "))))
          (redraw (setq ent2 (car ent2)) 3)
        )
        ;; Find the endpoints of the lines
        (setq lin1ps (entget ent1))
        (setq lin1pt1 (cdr (setq org10 (assoc 10 lin1ps))))
        (setq lin1pt2 (cdr (setq org11 (assoc 11 lin1ps))))
        (setq lin2ps (entget ent2))
        (setq lin2pt1 (cdr (assoc 10 lin2ps)))
        (setq lin2pt2 (cdr (assoc 11 lin2ps)))
        ;; Get all of the possible distances and group them with
        ;; their corresponding endpoints
        (setq dis1 (distance lin1pt1 lin2pt1))
        (setq dis2 (distance lin1pt1 lin2pt2))
        (setq dis3 (distance lin1pt2 lin2pt1))
        (setq dis4 (distance lin1pt2 lin2pt2))
        (setq dislist
          (list
            (list dis1 lin1pt1 lin2pt1)
            (list dis2 lin1pt1 lin2pt2)
            (list dis3 lin1pt2 lin2pt1)
            (list dis4 lin1pt2 lin2pt2)
          )
        )
        ; Get the farthest distance and the endpoints associated with them
        (setq maxdis (max dis1 dis2 dis3 dis4))
        (setq pts (cdr (assoc maxdis dislist)))
        (setq pt1 (car pts))
        (setq pt2 (cadr pts))
        ;; Erase the second entity and update the first
        (setq lin1ps (subst (cons 10 pt1) org10 lin1ps))
        (setq lin1ps (subst (cons 11 pt2) org11 lin1ps))
        (entdel ent2)
        (entmod lin1ps)
        (entupd ent1)
        (setq ent1 (entsel "\nSelect first line: "))
      )
     ;;; (arctvrst)
      (princ)
    )




     



     



    HTH



     





    --
    Jamie Duncan



     



    "Maybe the Hokey Pokey is REALLY what's it all about"



     



     



     




    --




     



    Jamie Duncan



     



    Consulting - If you're not part of the solution, there's good money in prolonging the problem.



    "pthomas3" <> wrote in message news:...

    Is there a command in AutoCAD 2002, that allows you to mend a broken line, arc, whatever?
    I've just been using the extend or fillet commands, but it just seems that there should be a simple command that fills in a gap when you delete and intersecting entity.
    Thanks!
     
    Jamie Duncan, Aug 7, 2003
    #2
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.