Humbertogo 发表于 2006-9-28 06:50:23

ObjectDBX

有没有办法用ObjectDBX读取一些系统变量?
**** Hidden Message *****

Jeff_M 发表于 2006-9-28 13:07:06

不,我不知道

FengK 发表于 2006-9-28 13:20:49

我模模糊糊地记得,它返回了执行代码的当前图形中的系统变量(可能是错误的)
建议:将感兴趣的系统变量存储在自定义字典中,或作为扩展数据附加到图形中的某些对象,以后可以通过objectdbx访问它们。

deegeecees 发表于 2006-9-28 14:31:50

由于ObjectDBX对未打开的图纸最有用,并且AutoCAD的系统变量要么存储在图纸中,要么存储在应用程序级别,那么您为什么(如果我可以大胆地问的话)要阅读它们?
只是想知道您想做什么。

Humbertogo 发表于 2006-9-28 17:22:47

我需要检查图纸是公制的还是英制的。
AutoCAD系统变量Measurement
0为英制
1为公制
用于将文件作为块打开或插入

Fatty 发表于 2006-9-29 05:59:24

不确定确切,但我认为
这将是不可能做到与ObjectDBX方法恕我直言
试试这个:
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 dmod0 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
Fatty
~'J'~

Humbertogo 发表于 2006-9-29 07:56:51

您使用的是什么版本的AutoCAD?

Humbertogo 发表于 2006-9-29 09:04:32

我用Autocad mechanical 2006

Humbertogo 发表于 2006-9-29 10:53:04

在这种情况下,我认为有一种方法可以通过使用C#或 VB.NET.NET API来实现。
你有兴趣试一试吗?

Humbertogo 发表于 2006-9-29 11:06:24


哦,是的,我是
页: [1] 2
查看完整版本: ObjectDBX