Code:
;;;we can set the hatch pattern, scale and ofset diastance later.. N. Adam
;;;and you can select more than one lwpolylines, this time only for one pline..
;;;if this is okey, I'll change for multiple selection.
(defun c:h1 ()
(setq ofdis 100)
(setq pl1 (ssget":L"'((0 . "LWPOLYLINE"))))
(if (= pl1 nil)(alert "No PolyLine Selected")(YES)
)
(princ)
)
(defun yes ()
(setq pl1-0 (ssname pl1 0))
(setq pl1-1 (entget pl1-0))
(setq pl1-2 (reverse pl1-1))
(setq ref-p1 (cdr(assoc 10 pl1-1)))
(command "copy" pl1-0 "" ref-p1 ref-p1)(setq props (entlast))
(setq pl1-1 (subst (cons 100 "0")(assoc 10 pl1-1) pl1-1))
(setq ref-p2 (cdr(assoc 10 pl1-1)))
(setq ref-p4 (cdr(assoc 10 pl1-2)))
(setq pl1-2 (subst (cons 100 "0")(assoc 10 pl1-2) pl1-2))
(setq ref-p3 (cdr(assoc 10 pl1-2)))
(setq ang1 (angle ref-p2 ref-p1))(setq ang1-a (+ ang1 1.5708))
(setq newp1 (polar ref-p1 ang1 ofdis))
(setq ang2 (angle ref-p3 ref-p4))(setq ang2-a (+ ang2 1.5708))
(setq newp2 (polar ref-p4 ang2 ofdis))
(setq newp3 (polar newp1 ang1-a ofdis))
(setq newp4 (polar newp2 ang2-a ofdis))
(setq props1 (entget props) props2 (reverse props1))
(setq props1 (subst (cons 10 newp1)(assoc 10 props1) props1))
(setq props2 (subst (cons 10 newp2)(assoc 10 props2) props1))
(entmod props1)(entmod props2)
(command "offset" ofdis props newp3 "")(setq of1 (entlast))
(command "offset" ofdis props newp4 "")(setq of2 (entlast))
(command "erase" props "")
(setq ofs1 (cdr(assoc 10 (entget of1))))
(setq ofs2 (cdr(assoc 10 (entget of2))))
(command "pline" ofs1 ofs2 "")(setq of3 (entlast))
(command "pedit" of1 "j" of2 of3 "" "c" "")
(command "-bhatch" "s" (entlast) "" "")
)