乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 70|回复: 4

[编程交流] routine to list all layer'

[复制链接]

5

主题

45

帖子

40

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 11:09:42 | 显示全部楼层 |阅读模式
Do you know any routine to list all layer's names in a text file or Excel sheet?
Please help. Tkx.
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-6 11:25:54 | 显示全部楼层
Phiphi:
 
It is generally not a good idea to append a new question to an existing thread even if the subject seems to be similar.  In the future, start a new thread.  Thanks.
 
But don't be too disappointed.  I found exactly what you need at the link below.  When you get to the web page, scroll down to the section called Layer Management and look for a routine called laylst.lsp.  This lisp routine will, according to its author, "generate a sorted list of layer names in a drawing".
 
http://paracadd.com/lisp.htm
 
By the way, the tip jar is on the counter.
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 11:51:00 | 显示全部楼层
 
Open the Layer Manager>Select all (Ctrl+A)>Copy (Ctrl+C)>Open Excel or Notepad and paste the contents.
回复

使用道具 举报

8

主题

1647

帖子

1647

银币

初来乍到

Rank: 1

铜币
36
发表于 2022-7-6 11:58:25 | 显示全部楼层
 
I've used this routine in the past. Don't know who wrote it or where I got it. I've had it for ages.
 
 
Edit: This request has been moved to it's own thread and placed in the Customization section.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:21:01 | 显示全部楼层
I wrote this a while back, will process all drawings in a directory (and subdirectories):
 
  1. (defun c:CheckLayers ( / *error* DBX DOCLST FILES FLAG LAYER_LIST ODOC OFILE OUTFILE SHELL ) (vl-load-com) ;; Lee Mac  ~  15.01.10 (defun *error* (msg)   (ObjRelease (list Shell dbx))   (and ofile (= (type ofile) 'FILE) (close ofile))      (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) ) (setq *acad (cond (*acad) ((vlax-get-acad-object)))       *doc  (cond (*doc ) ((vla-get-ActiveDocument *acad)))) (if (and (setq Files   (GetAllFiles nil t "*.dwg"))          (setq outfile (getfiled "Output File" "" "txt" 1)))   (progn          (vlax-for doc (vla-get-Documents *acad)       (setq DocLst         (cons           (cons (strcase (vla-get-FullName doc)) doc) DocLst         )       )     )           (setq dbx (ObjectDBXDocument))          (foreach dwg Files       (cond         (  (setq flag              (and                (setq oDoc                  (cdr (assoc (strcase dwg) DocLst))                )              )            )          )         (t           (setq flag             (not               (vl-catch-all-error-p                 (vl-catch-all-apply                   (function vla-open) (list dbx dwg)                 )               )             )           )           (setq oDoc dbx)         )       )       (setq Layer_List         (if flag           (cons (cons dwg (GetLayerProperties oDoc)) Layer_List)           (cons (cons dwg '(("**Error Opening this Drawing **"))) Layer_List)         )       )     )     (princ (strcat "\n>"))   )       (princ "*Cancel*") ) (vlax-release-object dbx) (gc) (gc) (if (and Layer_List (setq ofile (open outfile "w")))   (progn           (mapcar       (function         (lambda (x)           (write-line (car x) ofile)           (write-line (MakeString '("Name" "Colour" "LineType" "LineWeight") (chr 32)) ofile)           (mapcar             (function               (lambda (y)                 (write-line                   (MakeString y (chr 32)) ofile                 )               )             )             (cdr x)           )                       (write-line "\n" ofile)         )       )       Layer_List     )     (close ofile)   )   (princ "\n*Cancel*") ) (princ))(defun ObjectDBXDocument ( / acVer ) (setq *acad (cond (*acad) ((vlax-get-acad-object))))  (vla-GetInterfaceObject *acad   (if (< (setq acVer (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument"     (strcat "ObjectDBX.AxDbDocument." (itoa acVer))   ) ))(defun GetAllFiles ( Dir Subs Filetype / GetSubFolders Shell Fold Dir ) (vl-load-com) ;; Lee Mac  ~  17.01.10  (defun GetSubFolders ( folder / _f )   (mapcar     (function       (lambda ( f ) (setq _f (strcat folder "\" f))         (cons _f (apply (function append)                         (GetSubFolders _f)))       )     )     (cddr (vl-directory-files folder nil -1))   ) ) (cond   ( (not       (or         (and Dir (vl-file-directory-p Dir))         (progn           (setq Shell (vla-getInterfaceObject                         (setq acad (vlax-get-acad-object)) "Shell.Application")                 Fold  (vlax-invoke-method Shell 'BrowseForFolder                         (vla-get-HWND acad) "Select Directory" 512))           (vlax-release-object Shell)                      (if Fold             (progn               (setq Dir (vlax-get-property                           (vlax-get-property Fold 'Self) 'Path))               (vlax-release-object Fold)                              (and (= "\" (substr Dir (strlen Dir)))                    (setq Dir (substr Dir 1 (1- (strlen Dir)))))                              Dir             )           )         )       )     )   )   ( (apply (function append)       (vl-remove (quote nil)         (mapcar           (function             (lambda (Filepath)               (mapcar                 (function                   (lambda (Filename)                     (strcat Filepath "\" Filename)                   )                 )                 (vl-directory-files Filepath Filetype 1)               )             )           )           (append (list Dir)             (apply (function append)               (if subs (GetSubFolders Dir))             )           )         )       )     )   ) ))(defun GetLayerProperties ( doc / lst ) (vlax-for lay (vla-get-Layers doc)   (setq lst     (cons       (mapcar         (function           (lambda ( property )             (vl-princ-to-string               (vlax-get-property lay property)             )           )         )         '(Name Color Linetype LineWeight)       )       lst     )   ) )   (vl-sort lst   (function     (lambda (a b) (< (car a) (car b)))   ) ))(defun MakeString  ( lst del / Pad str x i ) (setq i 10)  (defun Pad ( Str Del Len )   (while (>= (strlen Str) Len) (setq Len (+ Len 5)))   (while (< (strlen Str) Len)     (setq Str (strcat Str Del))   )   Str )  (apply (function strcat)   (reverse     (cons (last lst)       (mapcar         (function           (lambda ( $str )             (Pad $str del (setq i (abs (- 40 i))))           )         )                   (cdr (reverse lst))       )     )   ) ))
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 11:27 , Processed in 0.727187 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表