Here's another way to go about it, that spares you the need to calculate where to draw Lines [HATCH figures that out for you], and therefore also all the resulting (intersectwith) business.
It works on Polylines of any variety [if 3D, must be planar]. So far, the Polyline must be in, or in a plane parallel to, the current working plane; if it's parallel-to but not in, the results will be in the current plane, not that of the Polyline, but it could easily be made to set the UCS to match the Polyline, if needed.
The Polyline can have arc segments [if you pick it on one of them, the subdivisions will be parallel to, and their spacings generated from, its chord].
(defun C:SDPA ; = Sub-Divide Polyline Area
(/ plsel pl dist minpt maxpt LL UR stepH stepV base pt pickpar prept hatch hdata lines)
(if
(and
(setq plsel (entsel "\nSelect closed Polyline on edge divisions are to be parallel to: "))
(wcmatch (cdr (assoc 0 (entget (setq pl (car plsel))))) "*POLYLINE")
(vlax-curve-isClosed pl) (vlax-curve-isPlanar pl)
(not (initget 7)); no Enter, no zero, no negative
(setq dist (getreal "\nDistance between parallel divisions: "))
); and
(progn ; then
(vla-getboundingbox (vlax-ename->vla-object pl) 'minpt 'maxpt)
(setq
LL (vlax-safearray->list minpt)
UR (vlax-safearray->list maxpt)
stepH (/ (- (car UR) (car LL)) 100)
stepV (/ (- (cadr UR) (cadr LL)) 100)
base (polar LL (/ pi 2) stepV)
pt base
pickpar (vlax-curve-getParamAtPoint pl (osnap (cadr plsel) "_nea"))
prept (vlax-curve-getPointAtParam pl (fix pickpar)); point at preceding vertex
); setq
(command
"_.isolateobjects" pl ""
"_.hatch" "_user"
prept (vlax-curve-getPointAtParam pl (1+ (fix pickpar))); angle
dist "_no" pl ""
); command
(setq
hatch (entlast)
hdata (entget hatch)
hdata (subst (cons 43 (car prept)) (assoc 43 hdata) hdata); set origin X
hdata (subst (cons 44 (cadr prept)) (assoc 44 hdata) hdata); & Y
); setq
(entmod hdata)
(command "_.explode" hatch)
; because somehow Hatch doesn't "go into effect" in time to affect Boundary
; command, even with (entupd), (redraw) and Regen; even though resulting
; Lines may not "appear" in the process, they do affect Boundary
(setq lines (ssget "_P"))
(command "_.boundary" "_advanced" "_island" "_no" "" "")
(repeat 99
(repeat 99 ; row of pick points
(command (setq pt (polar pt 0 stepH)))
); repeat
(setq base (polar base (/ pi 2) stepV) pt base); move up for next row
); repeat
(command
"" ; end Boundary
"_.erase" lines pl "" ; <-- omit pl here to retain original Polyline
"_.unisolateobjects"
); command
); progn
(prompt "\nNothing selected, or not a closed Polyline.")
); if
(princ)
); defun
Kent Cooper, AIA