NirantarVidyart 发表于 2022-7-6 08:00:58

中使用的填充图案列表

AutoCAD图形是否存储图形中使用的填充图案名称列表?
 
我探索了NamedObjDict,但什么也找不到。
 
我想将列表提取到文本(或xl)文档中以供进一步使用。
 
谢谢你的帮助。

ReMark 发表于 2022-7-6 08:13:39

您可以使用下面链接中包含的一点C代码来获取该信息。看来你不是第一个问这个问题的人。
 
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

hugha 发表于 2022-7-6 08:29:47

转储到ASCII DXF并查找图案填充。

MSasu 发表于 2022-7-6 08:31:33

可以创建图形中所有图案填充图元的列表,并研究其DXF代码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)
)

pBe 发表于 2022-7-6 08:48:22

轻微修改以防止“打印”重复名称
(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)
)
 
写入文件

(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)
)

MSasu 发表于 2022-7-6 08:59:37

可以在AutoCAD中执行类似操作-使用QSELECT命令选择所有图案填充图元并调用列表以显示其特征。

GP_ 发表于 2022-7-6 09:08:12

也可以尝试“数据提取”
页: [1]
查看完整版本: 中使用的填充图案列表