如何得到一个闭合的线段中的文本对象?
<P>这个闭合的线段可以是任何的形状。如果得到这个对象中的文本?</P><P>最好是VBA程序,谢谢!</P> <P>找出所有的文件,得出其包围的外框,做成面域,与闭合线段做的面域做比较。</P> SelectByPolygon 方法得到 <P>我的程序如下,为何总找不到文本?</P>
<P>Sub Example_Select()<BR> Dim ssetObj As AcadSelectionSet<BR> <BR> Dim ent As AcadEntity<BR> Dim Points<BR> Dim n As Integer<BR> <BR> ThisDrawing.SelectionSets.item(0).Delete<BR> Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")<BR> <BR> Dim FilterType(0) As Integer<BR> Dim FilterData(0) As Variant</P>
<P> FilterType(0) = 0<BR> FilterData(0) = "TEXT"<BR> Dim coor() As Double<BR> <BR> For Each ent In ThisDrawing.ModelSpace<BR> If ent.ObjectName = "AcDbPolyline" Then<BR> <BR> Points = ent.Coordinates<BR> n = UBound(Points)<BR> <BR> ReDim coor(n + (n + 1) / 2)</P>
<P> '因为画的线是2D的,改变坐标为3D<BR> For i = 0 To n Step 2<BR> coor(i) = Points(i)<BR> coor(i + 1) = Points(i + 1)<BR> coor(i + 2) = 0<BR> Next<BR> <BR> ssetObj.SelectByPolygon acSelectionSetWindowPolygon, coor, FilterType, FilterData<BR> <BR> If ssetObj.Count > 0 Then<BR> MsgBox "找到" & ssetObj.item(0).TextString<BR> Else<BR> MsgBox "没找到"<BR> End If<BR> <BR> End If<BR> Next<BR> ssetObj.Delete<BR>End Sub<BR></P> <P> '因为画的线是2D的,改变坐标为3D<BR> For i = 0 To n Step 2<BR> coor(i) = Points(i)<BR> coor(i + 1) = Points(i + 1)<BR> coor(i + 2) = 0<BR> Next<BR>这段程序改为如下:</P>
<P> j = 0<BR> For i = 0 To n Step 2<BR> coor(j) = Points(i)<BR> coor(j + 1) = Points(i + 1)<BR> coor(j + 2) = 0<BR> j = j + 3<BR> Next<BR></P> 同意斑竹的话,你选择出来实体后,再过滤就可以了啊
页:
[1]