NirantarVidyarthee Posted April 20, 2012 Posted April 20, 2012 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. Quote
ReMark Posted April 20, 2012 Posted April 20, 2012 You can obtain that information using a bit of C# code that is contained within the link below. It appears you weren't the first person to ever ask the question. http://through-the-interface.typepad.com/through_the_interface/2012/03/getting-the-list-of-hatch-patterns-available-in-the-current-autocad-drawing-using-net.html Quote
MSasu Posted April 21, 2012 Posted April 21, 2012 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) ) Quote
pBe Posted April 21, 2012 Posted April 21, 2012 (edited) 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 April 21, 2012 by pBe Quote
MSasu Posted April 21, 2012 Posted April 21, 2012 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. Quote
Recommended Posts
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.