(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 vertical lines: ")
(setvar "nomutt" 1)
(setq sset1 (ssget ":L" '((0 . "LINE"))))
(setvar "nomutt" 0)
(princ "\nSelect 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" )
(setq ans (getkword "\nChoose lines to be jumped over [Vertical/Horizontal]:"))
(if (eq ans "Vertical")(setq vflag t)(setq vflag nil))
(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 ip (vlax-curve-getclosestpointto ent1 ip))
(setq bp1 (polar ip ang (/ gap 2)))
(setq bp2 (polar ip (+ ang pi) (/ gap 2)))

(command "_.break" bp1 bp2)

(command "_.arc" bp1 "_E" bp2 "_A" 180.)

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

(c:jmp)

Advertisements