不太确定,但我认为这是不可能的,用ObjectDBX方法IMHO试试这个:
- Option Explicit
- Public Function GetVars(selfiles As Variant, sysVarName As String) As Variant
- Dim fName As String
- Dim acdoc As AcadDocument
- Dim sysvar() As Variant
- Dim m As Integer
- For m = 0 To UBound(selfiles)
- fName = selfiles(m)
- Set acdoc = Application.Documents.Open(fName, True)
- ReDim Preserve sysvar(m)
- sysvar(m) = acdoc.GetVariable(sysVarName)
- acdoc.Close
- Next m
- GetVars = sysvar
- End Function
- Public Sub FindFile(ByRef files As Collection, strDir, strExt)
- Dim strFileName
- If (Right(strDir, 1) "") Then
- strDir = strDir & ""
- End If
- strFileName = Dir(strDir & "*.*", vbDirectory)
- Do While (strFileName "")
- If (UCase(Right(strFileName, 3)) = UCase(strExt)) Then
- files.Add strDir & strFileName
- End If
- strFileName = Dir
- Loop
-
- End Sub
- Sub Test()
- Dim dmod
- dmod = ThisDrawing.GetVariable("SDI")
- If dmod 0 Then
- ThisDrawing.SetVariable "SDI", 0
- End If
- Dim path As String
- path = "D:\AUTOLISP\LISPS\PRIMITIVES\#FILE&S\PURGE" '' change your path here
- Dim collFiles As New Collection
- Call FindFile(collFiles, path, "DWG")
- Dim i As Integer
- ReDim selfiles(collFiles.Count - 1) As String
- For i = 1 To collFiles.Count
- selfiles(i - 1) = collFiles.Item(i)
- Next
- Dim sysvar() As Variant
- sysvar = GetVars(selfiles, "measurement")
- ThisDrawing.SetVariable "SDI", dmod
- Dim dataVar(999, 1) As Variant
- For i = 0 To UBound(sysvar)
- dataVar(i, 0) = selfiles(i)
- dataVar(i, 1) = sysvar(i)
- Next
- End Sub
脂肪;J#039~ |