;;; Jump Arc lines Intersection of "slanted" lines, that must be "vertical" and "horizontal"
;;; Modified by Igal Averbuh 2016 (added option to jump by arc over "slanted" lines and change arc direction)

(defun C:jmp(/ *error* ang ans bp1 bp2 elist1 elist2 entlist1 entlist2 gap ip osm nom pe1 pe2 ps1 ps2 sellist sset1 sset2 vflag)
(vl-load-com)
(defun *error* (msg)
(vla-endundomark (vla-get-activedocument
(vlax-get-acad-object))
)
(cond ((or (not msg)
(member msg '("console break" "Function cancelled" "quit / exit abort"))
)
)
((princ (strcat "\nError: " msg)))
)
(setvar "cmdecho" 1)
(if osm
(setvar "osmode" osm)
)
(if nom
(setvar "osmode" nom)
)
(princ)
)
(vla-startundomark (vla-get-activedocument
(vlax-get-acad-object))
)
(setq osm(getvar "OSMODE"))
(setvar "OSMODE" 0)
; (princ "\nZoom objects to be visible on screen: ")
;(command "_.zoom" "w" pause pause)
(setvar "nomutt" 0)
(setq nom (getvar "nomutt"))

(setvar "nomutt" 0)
(princ "\nSelect slanted vertical or vertical lines: ")
(setvar "nomutt" 1)
(setq sset1 (ssget ":L" '((0 . "LINE"))))
(setvar "nomutt" 0)
(princ "\nSelect slanted horizontal or horizontal lines: ")
(setvar "nomutt" 1)
(setq sset2 (ssget ":L" '((0 . "LINE"))))
(setvar "nomutt" 0)
(setq *gap* 1);<-- set your gap between lines here
(setq gap (getdist (strcat "\nSet a gap by 2 points : ")))
(cond ((not gap)(setq gap *gap*)))
(setq entlist1 (vl-remove-if 'listp(mapcar 'cadr (ssnamex sset1)))
entlist2 (vl-remove-if 'listp(mapcar 'cadr (ssnamex sset2))))
;(initget 1 "Vertical Horizontal" )
(princ "\nLines will be jumped over slanted Horizontal lines:")

(if vflag (progn
;;swap references to selected objects :
(setq sellist (list entlist1 entlist2)
entlist2(car sellist)
entlist1(cadr sellist))

(setq ang (/ pi 2))
)
(setq ang 0)
)
(foreach ent1 entlist1
(setq elist1 (entget ent1))
(setq ps1 (cdr (assoc 10 elist1)))
(setq pe1 (cdr (assoc 11 elist1)))
(foreach ent2 entlist2
(setq elist2 (entget ent2))
(setq ps2 (cdr (assoc 10 elist2)))
(setq pe2 (cdr (assoc 11 elist2)))
(setq ip (inters ps2 pe2 ps1 pe1 nil))
(setq intpt (inters ps2 pe2 ps1 pe1 nil))
(setq ang1 (angle ip ps1))
(setq ang2 (angle ip pe1))
(setq rspt (polar ip ang1 (/ gap 2)))
(setq rept (polar ip ang2 (/ gap 2)))
(setq bp1 (polar ip ang (/ gap 2)))
(setq bp2 (polar ip (+ ang pi) (/ gap 2)))

(setq od (getvar "osmode"))
(setvar "osmode" 0)

(command "_.break" rspt rept)

(command "arc" rspt "c" intpt rept)

(setq ende (entlast))
(if (/= (getstring "\nChange Arc Direction? [Y](No - Enter)") "")
(progn (command "erase" ende "")
(command "arc" rept "c" intpt rspt)
)
)
(setvar "osmode" od)
)
(princ "\Done")

)
; (command "_.zoom" "p")
(*error* nil)
(princ)
)
(prompt "\n >>> Type JMP to execute...")
(princ)

Advertisements