博客网 >

DBX-DwgScan
作者:分类:默认分类标签:
代码:

;;;************************************************************************
;;; Filename: DBX-DwgScan.LSP
;;; Author: David Stein
;;; Date: April 2002
;;; Purpose: ObjectDBX Drawing Scan Example for Visual LISP Developers Bible book
;;; Copyright (C)2002 David M. Stein, All Rights Reserved.
;;;************************************************************************
;;; Usage: (DWGSCAN tablename itemname drawings)
;;;
;;; Where:
;;; tablename = string name of table (ex. Blocks, Ltypes, DimStyles, etc.)
;;; itemname = string name of item to search for
;;; drawings = list of drawing filenames (full paths included for each)
;;;
;;; Returns: A list of filenames that contain the itemname being searched for.
;;;************************************************************************
;;; For use with AutoCAD 2000, 2000i and 2002 or related vertical products
;;; only. Will NOT work with R14, any LT or Inventor products.
;;; Must be compiled as a separate-namespace VLX application
;;;************************************************************************
(vl-doc-export 'dwgscan)
(vl-load-com)
(defun DLLRegister (dll)
(startapp "regsvr32.exe" (strcat "/s \"" dll "\""))
)
(defun ProgID->ClassID (ProgID)
(vl-registry-read
(strcat "HKEY_CLASSES_ROOT\\" progid "\\CLSID")
)
)
(defun DBX-Register (/ classname)
(setq classname "ObjectDBX.AxDbDocument")
(cond
((ProgID->ClassID classname))
((and
(setq server (findfile "AxDb15.dll"))
(DLLRegister server)
(ProgID->ClassID classname)
)
(ProgID->ClassID classname)
)
((not (setq server (findfile "AxDb15.dll")))
(alert
"Error: Cannot locate ObjectDBX Type Library (AxDb15.dll)..."
)
)
(T
(DLLRegister "ObjectDBX.AxDbDocument")
(or
(ProgID->ClassID "ObjectDBX.AxDbDocument")
(alert
"Error: Failed to register ObjectDBX ActiveX services..."
)
)
)
)
)
(defun DBX-GetTableList
(filename tblname / dbxdoc out name)
(cond
((findfile filename)
(if (not (DBX-Register))
(vl-exit-with-error
"\nUnable to register ObjectDBX from Visual LISP."
)
)
(setq dbxdoc
(vla-GetInterfaceObject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
(cond
((vl-catch-all-error-p
(vl-catch-all-apply
'vla-Open
(list
dbxdoc
(findfile filename)
)
)
)
(princ (strcat "\nUnable to open drawing: " filename))
)
(T
(vlax-For tblItem (DBX-TableGet tblName dbxdoc)
(setq name (vla-get-Name tblItem))
(if (/= (substr name 1 1) "*")
(setq out
(cons name out)
)
)
)
)
) ; cond
(vlax-release-object dbxdoc)
)
(T
(strcat (princ "\nUnable to open file: " filename))
)
) ; cond
(if out
(reverse out)
)
)
(defun DBX-TableGet (tName object)
(cond
((= (strcase tName) "BLOCKS") (vla-get-Blocks object))
((= (strcase tName) "LAYERS") (vla-get-Layers object))
((= (strcase tName) "TEXTSTYLES")
(vla-get-textstyles object)
)
((= (strcase tName) "DIMSTYLES") (vla-get-dimstyles object))
((= (strcase tName) "LINETYPES") (vla-get-linetypes object))
((or
(= (strcase tName) "PLOTCONFIGURATIONS")
(= (strcase tName) "PAGESETUPS")
)
(vla-get-plotconfigurations object)
)
((= (strcase tName) "LAYOUTS") (vla-get-Layouts object))
((= (strcase tName) "GROUPS") (vla-get-Groups object))
(T
(vl-exit-with-error
"\n(dbx-dwgscan error): Invalid table name specified."
)
)
)
)
(defun DWGSCAN
($table $name $dwgfiles / $files
$dwgs $path $collection n
out
)
(cond
((and $table $name $dwgfiles)
(princ
(strcat
"\nScanning "
(itoa (length $dwgfiles))
" drawings for "
(strcase (substr $table 1 (1- (strlen $table))) t)
" ["
$name
"]..."
)
)
(foreach n $dwgfiles
(cond
((setq $collection (DBX-GetTableList n $table))
(cond
((member (strcase $name) (mapcar 'strcase $collection))
(setq out (cons n out))
)
)
(setq $collection nil)
)
;;( T (princ "\nUnable to query table collection in target drawing.") )
)
)
)
(T
(princ "\nUsage: (DWGSCAN tablename itemname drawingfiles)")
)
)
(if out
(reverse out)
)
)
(princ)
<< AutoCAD 2000启动时各... / 发图前处理下图形 Beta 0.... >>

专题推荐

不平凡的水果世界

不平凡的水果世界

平凡的水果世界,平凡中的不平凡。 今朝看水果是水果 ,看水果还是水果 ,看水果已不是水果。这境界,谁人可比?在不平凡的水果世界里,仁者见仁,智者见智。

中国春节的那些习俗

中国春节的那些习俗

正月是农历新年的开始,人们往往将它看作是新的一年年运好坏的兆示期。所以,过年的时候“禁忌”特别多。当然,各个地方的风俗习惯不一样,过年的禁忌也是不一样的。

评论
0/200
表情 验证码:

eachy

  • 文章总数0
  • 画报总数0
  • 画报点击数0
  • 文章点击数0
个人排行
        博文分类
        日期归档