|
|
发表于 2009-1-23 09:13:21
|
显示全部楼层
来自: 中国浙江宁波
使用VBA开发,利用objectdbx(免费)术,可以在打开CAD平台而不打开要查询的文件的情况下读取图纸中的信息!普通的objectdbx依赖CAD平台,不打开CAD平台的DBX技术要向autodesk公司购买;
& i z! H) k' M1 L例程:/ I- h7 \ Z5 F6 Q
Option Explicit+ @9 ~- N6 S5 P& q6 N4 G5 ^% j" s
Dim objDbx As AxDbDocument
7 l( n# h5 ^% P& R' E-' Example of batch for listing all layers on all drawings in a directory. & ]8 k2 ^/ ]$ b( y; A! z
Private Sub ListLayers() w2 ~5 `. ]8 N$ W
Set objDbx = GetInterfaceObject("ObjectDBX.AxDbDocument")) q: i9 @) n; c
Dim inDir As String
! K& E3 R+ C6 G$ Y4 u+ Y' M: C3 t6 VDim elem As Object* V# G2 R/ p% Z/ D- \! S# b9 X" m
Dim filenom As String @ D0 ]: F) k; a
Dim WholeFile As String7 S+ _7 g2 q) p
Dim newHeight As Double
1 X S1 ?: Z0 ]' m3 T$ linDir = "r:\projekt\3828\A"
" C3 \6 {6 S# Afilenom = Dir$(inDir & "\*.dwg")
% g- E) x& y4 t0 c9 O& E# k' r/ z" kDo While filenom <> ""( `" t- |- n; x; b* ~6 x9 Y
ThisDrawing.Utility.Prompt vbCrLf & "File: " & filenom
+ a1 e) q: N2 y# \. b ThisDrawing.Utility.Prompt vbCrLf & "-----------------", f3 Z' C! s$ X5 @! P
WholeFile = inDir & "\" & filenom
9 Y$ N' B" F8 _ q, g5 [( B% ` objDbx.Open WholeFile
4 f- s+ B, {5 j# F6 d6 V/ N( E0 f For Each elem In objDbx.Layers2 `2 i l4 x4 K5 C* M
ThisDrawing.Utility.Prompt vbCrLf & elem.Name
8 k5 J( u. B/ p8 t$ P) } Next2 h; h$ t: t# F8 u! ]+ p' R+ q
Set elem = Nothing
0 V9 s0 `$ E9 J7 Q objDbx.SaveAs WholeFile$ A0 W% M! {% s1 |0 Q) {
filenom = Dir$
% I, N3 _% F5 y/ S7 E/ {# }0 m ThisDrawing.Utility.Prompt vbCrLf* l+ u3 L& Y/ N5 H
Loop
/ a1 F' T6 ]) [+ z0 MEnd Sub
4 x6 L) g" ]$ u; O
) b E" l7 n U6 s) R对属性块的访问方法跟VBA访问方式相同;+ |, f8 C+ M$ K) B. {, z6 W1 m
; M& W5 n/ m8 a关于VLISP如何使用DBX可以到这看看:http://www.mjtd.com/a2/list.asp?id=315
2 s% l; e4 e% K- G2 z- m* G; C# ?8 k6 h
[ 本帖最后由 sealive_leafage 于 2009-1-23 09:23 编辑 ] |
评分
-
查看全部评分
|