本帖最后由 作者 于 2009-5-4 11:46:55 编辑
想破了头,查了很多资料,都想不出个办法来解决这个遍历问题。 问题就是在我建立了选择集后,用FOR EACH遍历获得实体进行实时操作。 这里有个TEXT数组接受数据。 而 For i = 0 To Num - 1 For Each entry In ssetobj entHandle = entry.handle entry.Highlight (True) MsgBox "The handle of this object is " & entHandle, vbInformation, "Handle数值" Set entry = acadapp.ActiveDocument.HandleToObject(entHandle) entry.TextOverride = Text1(i).Text Next Next i 这段代码肯定是错误的,我的目的是要通过遍历获得实体,实时进行操作。不知道如何修改,请高手指教,不甚感激! 全代码: Dim ssetobj As AcadSelectionSet On Error Resume Next '建立选择集 acadapp.SelectionSets("test1").Delete Set ssetobj = acadapp.ActiveDocument.SelectionSets.Add("test1") '建立过滤器 AppActivate acadapp.Caption Dim fType(0) As Integer Dim fData(0) As Variant fType(0) = 8 fData(0) = "bz" Dim FilterType As Variant Dim FilterData As Variant FilterType = fType FilterData = fData ssetobj.Select acSelectionSetAll, , , fType, fData AppActivate Form1.Caption Dim i As Integer Dim Num As Integer Dim entHandle As String Dim entry As AcadEntity Num = ssetobj.Count For i = 0 To Num - 1 For Each entry In ssetobj entHandle = entry.handle entry.Highlight (True) MsgBox "The handle of this object is " & entHandle, vbInformation, "Handle数值" Set entry = acadapp.ActiveDocument.HandleToObject(entHandle) entry.TextOverride = Text1(i).Text Next Next i entry.Highlight (False) entry.Update ssetobj.Delete end sub |