jialiang168 发表于 2011-11-23 21:40:26

不开图获取该图档的外部参照(dwg,jpg,pdf),回传完整路径表

;不开图获取该图档的外部参照(dwg,jpg,pdf),并回传完整路径表

;以下是自已写的程序,不知道各位是否有更简单的方法,可否提供学习之用呢?

;例:(RMQQ_blkname_lst "C:\\AC-空调-冰水-3F.dwg")
(defun RMQQ_blkname_lst(dwgname / cadVer name dbx blklst blken blkmelst)
    (setq CadVer (substr (getvar "acadver") 1 2))(setq blkmelst nil)
    (setq name (strcat "ObjectDBX.AxDbDocument." CadVer))
    (setq dbx (vlax-create-object name));;创建dbx对象
    (setq acadobj (vlax-get-acad-object))
    (setq filesobj (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
    (setq SupportPath (vla-get-SupportPath filesobj))
    (setq SupportPath2(strcat SupportPath ";" (vl-filename-directory dwgname)))
    (vla-put-SupportPath filesobj SupportPath2)
    (vla-open dbx dwgname);dwgname路径档名
    (setq blklst (vla-get-blocks dbx));取得图块的合集
    (vlax-for blken blklst
      (if (= :vlax-true (vla-get-isxref blken))
(progn
(if(=(setq blkxttme (findfile(vl-filename-base (vla-get-Path blken))))nil)
    (setq blkxttme (findfile (vla-get-Path blken)))
    )
(setq blkmelst(append blkmelst (list blkxttme)));路径回传成表
)
)
      )
    (setq modelss (vla-get-modelspace dbx));模型空间所有物件合集
    (setq Paperss (vla-get-PaperSpace dbx));图纸空间所有物件合集
    (setq mamet (list modelss Paperss))
    (while mamet
      (setq elss (car mamet)mamet(cdr mamet))
      (vlax-for blken elss
(cond((= (vla-get-objectname blken) "AcDbRasterImage");jpg
      (progn
(if(=(setq blkxttme (findfile(vl-filename-base (vla-get-ImageFile blken))))nil)
(setq blkxttme (findfile (vla-get-ImageFile blken)))
)
(setq blkmelst(append blkmelst (list blkxttme)));取得单一图块成表
))
   ((= (vla-get-objectname blken) "AcDbPdfReference");pdf
      (progn
(if(=(setq blkxttme (findfile(vl-filename-base (vla-get-File blken))))nil)
(setq blkxttme (findfile (vla-get-File blken)))
)
(setq blkmelst(append blkmelst (list blkxttme)));取得单一图块成表
))
   )
)
      )
    (vlax-release-object dbx)
    (vla-put-SupportPath filesobj SupportPath)
    blkmelst
    )

jack093 发表于 2012-6-29 09:52:08

好东西,不过速度如何?估计有点慢

cghdy 发表于 2020-5-6 21:16:46

拜读,真的是好东西

520kim 发表于 2023-12-1 22:10:24


;不开图获取该图档的外部参照(dwg,jpg,pdf),并回传完整路径表
请教一下怎么用不了的,

520kim 发表于 2023-12-1 22:12:06

cghdy 发表于 2020-5-6 21:16
拜读,真的是好东西

这位前辈,您在什么版本试用成功
页: [1]
查看完整版本: 不开图获取该图档的外部参照(dwg,jpg,pdf),回传完整路径表