I am looking for a lisp to generate hatch for multiple polygon separately?

I am looking for a lisp to generate hatch for multiple polygon separately?

giscivil92
Advocate Advocate
835 Views
5 Replies
Message 1 of 6

I am looking for a lisp to generate hatch for multiple polygon separately?

giscivil92
Advocate
Advocate

Hi Everyone

I am looking for a lisp to generate multiple hatch for multiple polygons  separately?

0 Likes
Accepted solutions (2)
836 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

Is there some issue you need to help with?

0 Likes
Message 3 of 6

hak_vz
Advisor
Advisor
Accepted solution
(defun c:mhatch (/ ang do-it doc hatch oname pname scl space ss)
	(if (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE"))))
		(progn
			(setq 
				scl (getvar 'hpscale)
				ang (getvar 'hpang)
				pname (getvar 'hpname)
				hpassoc (if (= (getvar 'hpassoc) 1):vlax-true :vlax-false)
				doc (vla-get-activedocument (vlax-get-acad-object))
				space (if (= (getvar 'cvport) 1) (vla-get-paperspace doc) (vla-get-modelspace doc))
			)
			(vlax-for ent (vla-get-activeselectionset doc)
				(setq 
					do-it nil
					oname (strcase (vla-get-objectname ent))
				)
				(cond 
					((vl-string-search "CIRCLE" oname)(setq do-it t))
					((and (vl-string-search "LINE" oname)(eq (vla-get-closed ent) :vlax-true))(setq do-it t))
					((equal (vlax-curve-getstartpoint ent) (vlax-curve-getendpoint ent) 1e-6)(setq do-it t))
				)
				(if do-it
					(progn
						(setq hatch (vlax-invoke space 'addhatch acHatchObject pname hpassoc))
						(vlax-invoke hatch 'appendouterloop (list ent))
						(vlax-put hatch 'patternangle ang)
						(vlax-put hatch 'patternscale scl)
						(vla-evaluate hatch)
					)
				)
			)
		)
	)
	(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

Can't you just use the regular Hatch command, and in its dialog box, check this option?

Kent1Cooper_0-1709293087638.png

Kent Cooper, AIA
0 Likes
Message 5 of 6

ronjonp
Advisor
Advisor

@giscivil92 Also look into the HPSEPARATE variable. Code is not needed for this task.

0 Likes
Message 6 of 6

giscivil92
Advocate
Advocate

@Kent1Cooper Hello Kent thanks for sharing, actually I didn't know about this capability in Autocad, that's it I need 

Thanks again

0 Likes