[求助]帮看下这段代码
<P>主要功能是实现,在选中多个布局中的两个文字,在文字下方画线,同时修改颜色和大小</P><P>存在问题是,在选择文字时。很多时候选不上文字,但如果只有一个布局时,又可以选择上。多个布局时,很多布局上的选不上。</P>
<P>Sub Example_PaperUnits()<BR> ' This example will access the Layouts collection for the current drawing<BR> ' and list basic information about the paper units used for each Layout.</P>
<P> Dim Layouts As AcadLayouts, Layout As AcadLayout<BR> Dim ssetObj As AcadSelectionSet<BR> Dim CONUT As Integer<BR> Dim FilterType(1) As Integer<BR> Dim FilterData(1) As Variant<BR> Dim lend As Variant<BR> Dim corner1(0 To 2) As Double<BR> Dim corner2(0 To 2) As Double<BR> Dim lineObj As AcadLine<BR> <BR> ' Get layouts collection from document object<BR> Set Layouts = ThisDrawing.Layouts<BR> </P>
<P> <BR> For Each Layout In Layouts<BR> <BR> <BR> ThisDrawing.SetVariable "CTAB", Layout.Name<BR> <BR> CONUT = 0<BR> Count = ThisDrawing.SelectionSets.Count<BR> For i = 0 To Count - 1 '删除所有的选择集<BR> Set ssetObj = ThisDrawing.SelectionSets.Item(0)<BR> ssetObj.Delete<BR> Next i<BR> ' ThisDrawing.ActiveSpace = acModelSpace<BR> <BR> Set ssetObj = ThisDrawing.SelectionSets.Add("sjx")<BR> FilterType(0) = 0<BR> FilterData(0) = "text"<BR> FilterType(1) = 8<BR> FilterData(1) = "TK_STA"<BR> <BR> </P>
<P> 'ssetObj.Select acSelectionSetAll, , , FilterType, FilterData<BR> ssetObj.Select acSelectionSetCrossing, corner1, corner2, FilterType, FilterData<BR> <BR> For Each entry In ssetObj<BR> 'MsgBox entry.TextString<BR> lend = entry.TextAlignmentPoint<BR> <BR> corner1(0) = lend(0) + 20 * Cos(entry.Rotation): corner1(1) = lend(1) + 20 * Sin(entry.Rotation)<BR> corner2(0) = lend(0) + 20 * Cos(entry.Rotation + 3.1415926): corner2(1) = lend(1) + 20 * Sin(entry.Rotation + 3.1415926)<BR> <BR> Set lineObj = ThisDrawing.PaperSpace.AddLine(corner1, corner2)<BR> lineObj.color = 6<BR> lineObj.Update<BR> Count = 4<BR> entry.Height = Count<BR> entry.color = 6<BR> entry.Update<BR> Next entry<BR> corner1(0) = 21: corner1(1) = 15: corner1(2) = 0<BR> corner2(0) = 400: corner2(1) = 260: corner2(2) = 0<BR> <BR> Next<BR> <BR> 'ThisDrawing.SetVariable "CTAB", Layout.Name</P>
<P>End Sub</P> ssetObj.Select acSelectionSetCrossing, corner1, corner2, FilterType, FilterData<BR>之前怎么没见你给corner1,和corner2赋值? <P>后边的也不行啊。同一个布局,根本就选不上。不过只要把其他的布局都删了,就可以了。</P>
<P>所有的布局都是一个程序自动生成的,如果你每一个布局都点一个就可以选取上了。要不一直是选取不上的。不知道如果解决。</P>
页:
[1]