[求助]求仅选择块内文字的选择集代码
<p>首先祝大家新年快乐.万事如意.心想事成!</p><p>求:1.仅选择模型空间中所有块内文字的选择集代码;2.选择模型空间中除块内文字之外的所有文字的选择集代码。</p><p>谢谢</p><p>黄玉宏 1.30</p> <p> 再次请教各位,请帮忙.</p><p> 谢谢!</p> 本帖最后由 作者 于 2009-2-12 23:39:17 编辑 <br /><br /> <p>第一个问题:答案,TextSS自定义函数来完成,返回仅选择模型空间中所有块内文字的选择集,并从所有块中拷贝出来文字对象</p><p> test为测试子程序,显示所有块内的文字对象个数,检验是正确的</p><p>Sub test()<br/>Dim sss As AcadSelectionSet<br/>delSS<br/>Set sss = ThisDrawing.SelectionSets.Add("sss")<br/>Set sss = TextSS<br/>MsgBox sss.count<br/>End Sub</p><p>Public Function TextSS() As AcadSelectionSet<br/>Dim ss As AcadSelectionSet<br/>Dim aa(0 To 0) As AcadEntity<br/>Dim ppp As AcadEntity<br/>Dim NewEnt As AcadEntity<br/>Dim expp As Variant<br/>Dim i As Long<br/>Dim ii As Long</p><p>Set ss = ThisDrawing.SelectionSets.Add("ss")<br/> For i = 0 To ThisDrawing.ModelSpace.count - 1 '遍历模型空间所有对象<br/> Set NewEnt = ThisDrawing.ModelSpace.Item(i)<br/> If NewEnt.ObjectName = "AcDbBlockReference" Then<br/> expp = NewEnt.Explode<br/> For ii = 0 To UBound(expp)<br/> Set ppp = expp(ii)<br/> If ppp.ObjectName = "AcDbText" Then<br/> Set aa(0) = ppp<br/> ss.AddItems aa<br/> Else<br/> ppp.Delete<br/> End If<br/> Next ii<br/> End If<br/> Next i<br/>Set TextSS = ss<br/>End Function</p><p>Public Function delSS()<br/>Do While ThisDrawing.SelectionSets.count > 0 '=====安全创建选择集<br/> ThisDrawing.SelectionSets.Item(0).Delete<br/>Loop<br/>End Function</p><p>第2给问题就更简单了:答案,TextSS2自定义函数来完成,选择模型空间中除块内文字之外的所有文字的选择集,</p><p> test2为测试子程序,显示所有除块内文字之外的文字对象个数,检验是正确的</p><p>Sub test2()<br/>Dim sss As AcadSelectionSet<br/>delSS<br/>Set sss = ThisDrawing.SelectionSets.Add("sss")<br/>Set sss = TextSS2<br/>MsgBox sss.count<br/>End Sub</p><p>Public Function TextSS2() As AcadSelectionSet<br/>Dim ss As AcadSelectionSet<br/>Dim aa(0 To 0) As AcadEntity<br/>Dim NewEnt As AcadEntity<br/>Dim i As Long<br/>Set ss = ThisDrawing.SelectionSets.Add("ss")<br/> For i = 0 To ThisDrawing.ModelSpace.count - 1 '遍历模型空间所有对象<br/> Set NewEnt = ThisDrawing.ModelSpace.Item(i)<br/> If NewEnt.ObjectName = "AcDbText" Then<br/> Set aa(0) = NewEnt<br/> ss.AddItems aa<br/> End If<br/> Next i<br/>Set TextSS2 = ss<br/>End Function</p><p>Public Function delSS()<br/>Do While ThisDrawing.SelectionSets.count > 0 '=====安全创建选择集<br/> ThisDrawing.SelectionSets.Item(0).Delete<br/>Loop<br/>End Function</p>
页:
[1]