历遍多个布局求助
<P>Option Explicit</P><P>Private Sub CommandButton1_Click()<BR>Dim layo As AcadLayout<BR>Dim sset As AcadSelectionSet<BR>Dim str1 As String<BR>Dim oldstr As String<BR>Dim newstr As String<BR>Dim ftype(0) As Integer<BR>Dim fdata(0) As Variant<BR>Dim point1(0 To 2) As Double<BR>Dim point2(0 To 2) As Double<BR>Dim i As Integer<BR>Dim abc As Object</P>
<P>ftype(0) = 0<BR>fdata(0) = "TEXT"<BR>oldstr = "a"<BR>newstr = "e"<BR>point1(0) = 343<BR>point1(1) = 272.5<BR>point1(2) = 0<BR>point2(0) = 403<BR>point2(1) = 280<BR>point2(2) = 0<BR>UserForm1.Hide</P>
<P>'以下建立选择集<BR>On Error Resume Next<BR> If Not IsNull(ThisDrawing.SelectionSets.Item("ss1")) Then<BR> Set sset = ThisDrawing.SelectionSets.Item("ss1")<BR> sset.Delete<BR> End If<BR> Set sset = ThisDrawing.SelectionSets.Add("ss1")<BR> sset.Clear<BR>'选择集建立完毕<BR>'%%%%%%%%%%%%%%%%%之间的部分有问题<BR>For i = 0 To ThisDrawing.Layouts.Count - 1 Step 1<BR>Set abc = ThisDrawing.Layouts.Item(0)<BR> sset.Clear<BR> sset.Select acSelectionSetWindow, point1, point2, ftype, fdata<BR> str1 = sset.Item(0).TextString<BR> If InStr(str1, oldstr) Then<BR> sset.Item(0).TextString = replacestr(str1, oldstr, newstr, False)'调用下面函数<BR> 'sset.Item(0).Update<BR> ThisDrawing.Regen acAllViewports</P>
<P> End If<BR> Next i<BR>'%%%%%%%%%%%%%%%%%%%%%以上有问题<BR>End Sub<BR>'以下函数执行替换==========================================================================<BR>Public Function replacestr(ByVal searchstr As String, ByVal oldstr As String, ByVal newstr As String, ByVal firstonly As Boolean) As String<BR>If searchstr = "" Then Exit Function<BR>If oldstr = "" Then Exit Function<BR>Dim i As Integer, oldstrlen As Integer, holdstr As String, strloc As Integer<BR>replacestr = ""<BR>oldstrlen = Len(oldstr)<BR>strloc = InStr(searchstr, oldstr)<BR>While strloc > 0<BR> holdstr = holdstr & Left(searchstr, strloc - 1) & newstr<BR> searchstr = Mid(searchstr, strloc + oldstrlen)<BR> strloc = InStr(searchstr, oldstr)<BR> If firstonly Then replacestr = holdstr & searchstr: Exit Function<BR>Wend<BR>replacestr = holdstr & searchstr<BR>End Function<BR>'===================================================</P>
<P>图形有2个布局,在每个布局中,在(343,272.5)与(403,280)范围内有一个text:内容为"hah",我想把他变成"heh",可是上面的程序只能对当前显示的布局有效,对其他布局没作用不知道为什么,麻烦各位给看看吧</P> <P> ThisDrawing.SetVariable "CTAB", Layout.Name</P>
<P>加上这一句,使他变成当前布局.</P>
页:
[1]