Jump to content

List of hatch patterns used in a drawing


NirantarVidyarthee

Recommended Posts

Does an AutoCAD drawing store the list of hatch pattern names used in the drawing?

 

I explored NamedObjDict but I could not find anything.

 

I want to extract the list into a text (or xl) document for further use.

 

Thanks for any help.

Link to comment
Share on other sites

You can create a list of all hatch entities in drawing and investigate their DXF code 2:

;;; Extract Hatch Paterns in Use (21-IV-2012)
(defun c:EHPU( / *listPattern* index listHatch  )
(setq index -1
      *listPattern* '())
(if (setq listHatch (ssget "_X" '((0 . "HATCH"))))
 (repeat (sslength listHatch)
  (prompt (strcat "\n" (car (setq index (1+ index)
                                  *listPattern* (cons (cdr (assoc 2 (entget (ssname listHatch index))))
                                                      *listPattern*)))))
 )
)
(if *listPattern* (textscr) (prompt "\nNo hatch patterns to list."))
(princ)
)

Link to comment
Share on other sites

slight mod to prevent "printing" duplicate names

(defun c:EHPU (/ *listPattern* nm listHatch)
 (if (setq *listPattern* nil
    listHatch   (ssget "_X" '((0 . "HATCH")))
     )
   (repeat (setq i (sslength listHatch))
     (if (not (member (setq nm
        (cdr
   (assoc 2 (entget (ssname listHatch (setq i (1- i)))))
        )
        )
        *listPattern*
       )
  )
(progn
  (print nm)
  (setq *listPattern* (cons nm *listPattern*))
)
     )
   )
   (prompt "\nNo hatch patterns to list.")
 )
 (princ)
)

 

Write to file

(defun c:WTFH (/ file *listPattern* listHatch)
 (cond ((and
   (eq (getvar 'DwgTitled) 1)
   (setq *listPattern* nil
  listHatch     (ssget "_X" '((0 . "HATCH")))
   )
   (setq file (open (strcat (getvar 'DwgPrefix)
       (cadr (fnsplitl (getvar 'DwgName)))
       ".txt"
      )
      "W"
       )
   )
   (repeat (setq i (sslength listHatch))
     (if (not (member (setq nm
        (cdr
          (assoc 2 (entget (ssname listHatch (setq i (1- i)))))
        )
        )
        *listPattern*
       )
  )
       (progn
  (write-line nm file)
  (print nm)
  (setq *listPattern* (cons nm *listPattern*))
       )
     )
   )
   (close file)
 )
)
 )
 (princ)
)

Edited by pBe
Link to comment
Share on other sites

Dump to ASCII DXF and look for HATCH.

Can do something similar inside AutoCAD - use QSELECT command to select all hatch entities and call LIST to display their features.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...