@s_plant wrote:
Only thing that I cannot figure it how include it in my lisp is: if nothing select it means all hatch patterns on drawing should be deleted. What is the lisp modification for zero-selection and delete all hatches?
Hi s_plant,
the following code deletes the hatches even without any selecion set.
(vl-load-com)
(defun c:demo (/ i layers locklstlat lst name obj ss)
(if (or (and (princ "\n Select hatch paterns to retain: ")
(setq ss (ssget '((0 . "HATCH"))))
)
(= (ACET-UI-MESSAGE
"Do you want to delete all hatches?"
"You are about to delete all hatches!!!"
(+ Acet:YESNO Acet:ICONWARNING)
)
6
)
)
(progn
(if ss
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
name (vla-get-patternname obj)
)
(if (not (vl-position name lst))
(setq lst (cons name lst))
)
)
)
(or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
(setq layers (vla-Get-Layers adoc))
(vlax-for lay layers
(if (= (vla-get-lock lay) :vlax-true)
(progn
(setq locklst (cons (vla-get-name lay) locklst))
(vla-put-lock lay :vlax-false)
)
)
)
(vlax-for blks (vla-get-blocks adoc)
(if (= :vlax-false (vla-get-isxref blks))
(vlax-for blk blks
(if (and (= (vla-get-objectname blk) "AcDbHatch")
(not (vl-position (vla-get-patternname blk) lst))
)
(vla-delete blk)
)
)
)
)
(if locklst
(vlax-for lay layers
(if (vl-position (vla-get-name lay) locklst)
(vla-put-lock lay :vlax-true)
)
)
)
(vla-Regen adoc acActiveViewport)
)
)
(princ)
)
@s_plant wrote:
Also it does not working on some hatches like the one, BUILDINGGP1 in attached drawing
s_plant,
in user defined hatch patterns, the pattern name property is always '_USER', so if you select one user defined hatch pattern the code will 'see' all the hatches with a pattern name '_USER' as de same pattern...
I do not use user defined hatch patterns, post a sample dwg with more user defined hatch patterns and i'll see what I can do.
Hope this helps,
Henrique