;;; Convert Polylines with Global Width to Solid Hatches
;;; Created by: ScottBolton on Feb 9, 2010
;;; Saved from here: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-polyline-with-global-width-to-hatch/td-p/2629709

(defun c:P2H ( / CONT COUNT END1 END2 ENT ENT1 ENT2 ENTFINAL OBJ OBJ1 OBJ2 SS SSTEMP START1 START2 WIDTH)
(setq ss (ssget)
count 0
)
(repeat (sslength ss)
(setq ent (ssname ss count)
obj (vlax-ename->vla-object ent)
cont (entget ent)
width (cdr (assoc 43 cont))
cont (subst '(43 . 0.0) (assoc 43 cont) cont)
)
(entmod cont)
(if (= 0.0 width) (setq width 1.0)); vla-object ent1)
obj2 (vlax-ename->vla-object ent2)
start1 (vlax-curve-getStartPoint obj1)
start2 (vlax-curve-getStartPoint obj2)
end1 (vlax-curve-getEndPoint obj1)
end2 (vlax-curve-getEndPoint obj2)
sstemp (ssadd)
)
(ssadd ent2 sstemp)
(entmake (append
'((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbPolyline") (90 . 2))
'((70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0))
(list (cons 10 start1))
'((40 . 5.0) (41 . 5.0) (42 . 0.0))
(list (cons 10 start2))
'((40 . 5.0) (41 . 5.0) (42 . 0.0) (210 0.0 0.0 1.0))
)
)
(ssadd (entlast) sstemp)
(entmake (append
'((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbPolyline") (90 . 2))
'((70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0))
(list (cons 10 end1))
'((40 . 5.0) (41 . 5.0) (42 . 0.0))
(list (cons 10 end2))
'((40 . 5.0) (41 . 5.0) (42 . 0.0) (210 0.0 0.0 1.0))
)
)
(ssadd (entlast) sstemp)
(command "_join" ent1 sstemp "")
(setq entfinal (entlast))
(command "_hatch" "_P" "_SOLID" entfinal "")
(entdel ent)
(entdel entfinal)
(setq count (1+ count))
)
)
(c:p2h)