This one might come in useful as well.
Code:
(DEFUN C:inter ()
;this section sets some preliminary variables for the program
(Setvar "CMDECHO" 0)
(setq ds (getvar "dimscale"))
(setq zdist (/ ds 3))
(setq counter 0)
(setq count2 1)
(setq ccount 0
lcount 0
)
(Setq pickold (getvar "pickbox"))
(setvar "pickbox" 7)
(prompt
"This program will explode all polylines to determine if individual line segments"
)
(terpri)
(prompt
"intersect other drawing objects. Wait 3 seconds or press esc now to exit"
)
(terpri)
(command "DELAY" "3000")
;This section makes a selection set of all poly lines and explodes them one by one
(setq sspl (ssget "X" '((0 . "LWPOLYLINE"))))
(if (/= sspl nil)
(setq sspllen (sslength sspl))
()
)
(setq pl 0)
(while (< pl sspllen)
(setq obj (ssname sspl pl))
(command "EXPLODE" obj "")
(setq pl (+ pl 1))
) ;while
;This section makes a selection set of all lines in the object database.
(setq ssl (ssget "X" '((0 . "LINE"))))
(setq sslen (sslength ssl))
;this section finds intersection points of lines and asks the user to break one
(while (< counter sslen)
(setq obja (ssname ssl counter))
(setq objadata (entget obja))
(setq astart (cdr (assoc 10 objadata)))
(setq aend (cdr (assoc 11 objadata)))
(while (< count2 sslen)
(setq objb (ssname ssl count2))
(setq objbdata (entget objb))
(setq bstart (cdr (assoc 10 objbdata)))
(setq bend (cdr (assoc 11 objbdata)))
(setq abint (inters astart aend bstart bend))
(if (or (equal bstart aend) (equal bend astart))
(setq abint nil)
()
) ;if
(if (/= abint nil)
(progn
(SETQ ZPOINT1 (POLAR ABINT 0.523 ZDIST))
(SETQ ZPOINT2 (POLAR ABINT 3.66 ZDIST))
(COMMAND "ZOOM" "WINDOW" ZPOINT1 ZPOINT2)
(setq BDIST 0.0443)
(setq OS (getvar "osmode"))
(setvar "osmode" 0)
(initget 1 "Yes No")
(setq test (getkword
"Would you like to break something here (Y/N)?"
)
)
(if (= test "Yes")
(progn
(setq ENT1
(car (entsel "\nSelect crossing line to break: "))
)
(setq LINE1 (entget ENT1))
(setq LN (cdr (assoc 8 LINE1)))
(setq P1 (cdr (assoc 10 LINE1)))
(setq P2 (cdr (assoc 11 LINE1)))
(setq AN (angle P1 P2))
(setq ENT2 (car (entsel "\nSelect line to cross over: ")))
(terpri)
(setq LINE2 (entget ENT2))
(setq P3 (cdr (assoc 10 LINE2)))
(setq P4 (cdr (assoc 11 LINE2)))
(setq IN (inters P1 P2 P3 P4))
(setq BPT1 (polar IN AN (* BDIST (getvar "dimscale"))))
(setq BPT2
(polar IN (+ AN pi) (* BDIST (getvar "dimscale")))
)
(command "break" ENT1 BPT1 BPT2)
(setvar "osmode" OS)
(Prompt "Pausing to show you your selection")
(terpri)
(command "DELAY" "1000")
) ;progn
) ;if
) ;progn
()
) ;if
(setq count2 (+ count2 1))
) ;while
(setq counter (+ counter 1))
(setq count2 (+ counter 1))
) ;while
(setvar "pickbox" pickold)
(Prompt
"Please run inters again to ensure all intersecting lines have been broken"
)
(terpri)
) ;defun