AutoLISP: Change Hatches to Solid Hatches

Today’s featured routine will help you if you need to change some or all hatches to the solid hatch pattern.

Here’s how:

  • HATCH2SOLID <enter>
  • Create a selection set by either individual selection or window/crossing selection.
  • Or
  • As shown in the animation: type ALL <enter> in the command line to select all hatches in the drawing.
  • Hit <enter> once more to except the selection set.

~enjoy


(defun c:Hatch2Solid (/ ss)
;;; Tharwat 01. April. 2012 ;;;
(vl-load-com)
  (cond ((not acdoc)
         (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
        )
  )
  (if (setq ss (ssget "_:L" '((0 . "HATCH") (2 . "~SOLID"))))
    (progn
      (vla-StartUndoMark acdoc)
      ((lambda (i / sn)
         (while
           (setq sn (ssname ss (setq i (1+ i))))
            (vla-setPattern
              (vlax-ename->vla-object sn)
              acHatchPatternTypePreDefined
              "SOLID"
            )
         )
       )
        -1
      )
      (vla-EndUndoMark acdoc)
    )
    (princ)
  )
  (princ)
)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Modify, Hatch, Modifying. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s