@abdalla.safwat wrote:
Anyone knows how to make that kind of hatch on Autocad, parallel lines that are connected from sides so it would start at a point go all the way through to the other side and move parallel and move back, it's basically all one long line. ....
This will make a Polyline that does that [not "make that kind of hatch," since a Hatch pattern can't be like that] for the second image only, in which there are no islands cut out of the middle. It takes advantage of the fact that when you Explode a Hatch pattern, all the resulting Lines end up as the "Previous" selection, and are in order across the Hatched area.
(defun C:PBFH ; = Polyline Back and Forth over Hatch
(/ hsel lss n bf ldata)
(if
(and
(setq hsel (entsel "\nSelect Hatch pattern of parallel lines to draw Polyline back and forth over: "))
(member '(0 . "HATCH") (entget (car hsel)))
); and
(progn ; then
(command "_.explode" (car hsel))
(setq
lss (ssget "_P"); the Lines resulting from Exploding
n (sslength lss); how many there are
bf 10 ; = Back/Forth -- initial code for end of Line to start at
); setq
(command "_.pline"); start one
(repeat n
(setq ldata (entget (ssname lss (setq n (1- n))))); next Line
(command
"_none" (cdr (assoc bf ldata)); start or end of Line
"_none" (cdr (assoc (setq bf (if (= bf 10) 11 10)) ldata)); other end
); command
); repeat
(command ""); end Polyline
); progn
); if
); defun
HOWEVER, it will not do what you have in your first image, because the order of resulting Lines puts those that are collinear next to each other, so the Polyline jumps across the hole. It's hard to imagine a way of getting it to do it as you want from a single Hatch pattern like that -- you would probably need to Hatch in separate pieces, or in newer versions in which Hatches can be Trimmed, draw some carefully positioned Lines between the zones, make in-place Copies of the Hatch, Trim to make them separate in each area, then run this on each piece. Or, you may be able to use what it does with a single pattern, with some editing [but a lot less editing than manually drawing all the Polylines].
It does not, but could be made to, check that the Hatch pattern selected is of a pattern with only parallel continuous lines, nor do anything about the current Layer or Polyline width settings, nor [if you want to do either of these] retain the original Hatch pattern nor eliminate the Lines resulting from Exploding it.
Kent Cooper, AIA