您可以使用 VBA 中的结构来可靠地访问图纸集组件。VBA 的 Microsoft 帮助包含结构的示例。Microsoft Help for VBA 可从 VBA IDE 的“帮助”菜单中获得。Do WhileDo While 要使用结构访问图纸集组件,请使用类似于 的语句来确定对象是否可用。例如,若要使用 a语句循环访问集合中的对象,可以使用以下代码:Do WhileDo While Not obj Is NothingDo While Not obj Is Nothing Public Function FindAllComponents(comps As Collection) As Boolean
On Local Error GoTo etrap
If comps Is Nothing Then Set comps = New Collection
Dim iter As IAcSmEnumPersist
Set iter = m_db.GetEnumerator
Dim obj As IAcSmPersist
Set obj = iter.Next
Do While Not obj Is Nothing
If TypeOf obj Is IAcSmComponent Then
Dim comp As IAcSmComponent
Set comp = obj
comps.Add comp
End If
Set obj = iter.Next
Loop
FindAllComponents = True
Exit Function
etrap:
MsgBox CStr(Err.Number) & " - " & Err.Description
End Function
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 14:11
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.