|
|
发表于 2009-1-23 09:13:21
|
显示全部楼层
来自: 中国浙江宁波
使用VBA开发,利用objectdbx(免费)术,可以在打开CAD平台而不打开要查询的文件的情况下读取图纸中的信息!普通的objectdbx依赖CAD平台,不打开CAD平台的DBX技术要向autodesk公司购买;2 ?+ n& L* e& E" Z2 \
例程:
% v% D& R' U$ ~* k1 {Option Explicit! B& W* g z, s; V1 G0 h
Dim objDbx As AxDbDocument
' G9 w' {, L' v- H) q% v3 |8 f' E-' Example of batch for listing all layers on all drawings in a directory. % C1 \9 x' ?& r/ l4 A
Private Sub ListLayers()
% j: ]- S; K* \ xSet objDbx = GetInterfaceObject("ObjectDBX.AxDbDocument"), G" j, w2 ^& v1 L) R5 _, Z1 a
Dim inDir As String
0 z, d4 _7 U: K; Z/ V aDim elem As Object P% h) _4 V1 d. ^
Dim filenom As String
2 J# n4 E' D5 S% w; }4 r& QDim WholeFile As String* g8 ]3 X* w* I; ~0 T
Dim newHeight As Double4 T: b7 A3 K) u" r4 K
inDir = "r:\projekt\3828\A"
/ J6 o( i$ B4 U3 m. P' T5 c' Hfilenom = Dir$(inDir & "\*.dwg")
0 D; t+ w* y$ w0 z1 oDo While filenom <> ""
% ] E) m# c+ M3 x ThisDrawing.Utility.Prompt vbCrLf & "File: " & filenom) E6 o1 B4 N" G. u: P
ThisDrawing.Utility.Prompt vbCrLf & "-----------------"
) |9 R6 q: n( K: t WholeFile = inDir & "\" & filenom; W, Y0 R) n1 C; p3 T4 B/ A V
objDbx.Open WholeFile |6 V3 ]0 @ e7 y0 `6 W
For Each elem In objDbx.Layers
& U. U5 Z& ^3 s- u [ ThisDrawing.Utility.Prompt vbCrLf & elem.Name
8 ^$ d; h6 X( A J0 U9 l Next
, P( e5 ]+ [- c" z% z4 \& c Set elem = Nothing7 n! _$ c" z, _! S) Y4 K0 Q
objDbx.SaveAs WholeFile
$ n) n% B& H; s filenom = Dir$
- y; I0 M2 c7 v0 H. ` ThisDrawing.Utility.Prompt vbCrLf
( ]8 }( @! ~7 J4 m% C- yLoop2 i" ^( g; _( m
End Sub
3 W: E& \$ H9 G; S
4 e( o. Y# t+ D% ]3 ^& A7 V对属性块的访问方法跟VBA访问方式相同;8 r. f. |7 W) r3 J( Y
- g) p0 a9 z' l# U
关于VLISP如何使用DBX可以到这看看:http://www.mjtd.com/a2/list.asp?id=315# I5 [6 h- S& y4 a. r8 m" @
( Q' ~& Q2 o( I, b/ F8 e4 ]6 @( k[ 本帖最后由 sealive_leafage 于 2009-1-23 09:23 编辑 ] |
评分
-
查看全部评分
|