兰州人 发表于 2009-8-29 17:27:00

选择集的and和or的应用.

<p>这种组合,实现只在"AA1"图层中,找line实体.</p><p>&nbsp;fType(0) = -4: fData(0) = "&lt;And"<br/>&nbsp;&nbsp;&nbsp; fType(2) = 0: fData(2) = "text"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "AA1"<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "And&gt;"<br/></p><p>Sub l()<br/>&nbsp; Dim sSet As AcadSelectionSet<br/>&nbsp; Dim fType(3) As Integer, fData(3) As Variant<br/>&nbsp; Dim sSetName As String<br/>&nbsp; sSetName = "First"<br/>&nbsp; With ThisDrawing<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not IsNull(.SelectionSets.Item(sSetName)) Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sSet = .SelectionSets.Item(sSetName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sSet.Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sSet = .SelectionSets.Add(sSetName)<br/>&nbsp;&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;And"<br/>&nbsp;&nbsp;&nbsp; fType(2) = 0: fData(2) = "text"<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "标题栏"<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "And&gt;"<br/>&nbsp;&nbsp;&nbsp; sSet.Select 5, , , fType, fData<br/>&nbsp;&nbsp;&nbsp; sSet.Highlight True<br/>&nbsp;&nbsp;&nbsp; 'Debug.Print sSet.Count<br/>&nbsp; End With<br/>End Sub</p><p>'''这种组合是图层aa1中的line和text实体</p><p>&nbsp;&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "AA1"<br/>&nbsp;&nbsp;&nbsp; fType(2) = -4: fData(2) = "Or&gt;"<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(4) = 0: fData(4) = "Line"<br/>&nbsp;&nbsp;&nbsp; fType(5) = 0: fData(5) = "Text"<br/></p><p>Sub ls()<br/>&nbsp; Dim sSet As AcadSelectionSet<br/>&nbsp; Dim fType(6) As Integer, fData(6) As Variant<br/>&nbsp; Dim sSetName As String<br/>&nbsp; sSetName = "First"<br/>&nbsp; With ThisDrawing<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not IsNull(.SelectionSets.Item(sSetName)) Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sSet = .SelectionSets.Item(sSetName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sSet.Delete<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sSet = .SelectionSets.Add(sSetName)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "AA1"<br/>&nbsp;&nbsp;&nbsp; fType(2) = -4: fData(2) = "Or&gt;"<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(4) = 0: fData(4) = "Line"<br/>&nbsp;&nbsp;&nbsp; fType(5) = 0: fData(5) = "Text"<br/>&nbsp;&nbsp;&nbsp; fType(6) = -4: fData(6) = "Or&gt;"<br/>&nbsp;&nbsp;&nbsp; sSet.Select 5, , , fType, fData<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Debug.Print sSet.Count<br/>&nbsp;&nbsp;&nbsp; sSet.Highlight True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp; End With<br/>End Sub</p><p><br/></p>

雪山飞狐_lzh 发表于 2009-8-29 19:04:00

<p>and在or内部才有用</p><p>选择集默认为and(与)</p><p>&nbsp;&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;And"</p><p>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "标题栏"<br/><br/>&nbsp;&nbsp;&nbsp; fType(2) = 0: fData(2) = "text"<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "And&gt;"</p><p>-》等效于</p><p>&nbsp;&nbsp;&nbsp; fType(0) = 8: fData(0) = "标题栏"<br/><br/>&nbsp;&nbsp;&nbsp; fType(1) = 0: fData(1) = "text"<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/></p>

雪山飞狐_lzh 发表于 2009-8-29 19:07:00

<p>&nbsp;&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "AA1"<br/>&nbsp;&nbsp;&nbsp; fType(2) = -4: fData(2) = "Or&gt;"<br/>&nbsp;&nbsp;&nbsp; fType(3) = -4: fData(3) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(4) = 0: fData(4) = "Line"<br/>&nbsp;&nbsp;&nbsp; fType(5) = 0: fData(5) = "Text"<br/>&nbsp;&nbsp;&nbsp; fType(6) = -4: fData(6) = "Or&gt;"</p><p>正确的写法:</p><p>8,"AA1",0,"Line,Text"</p>

542392339 发表于 2010-1-6 17:28:00

谢谢啦

yg545france 发表于 2010-2-1 23:15:00

<p>&nbsp;&nbsp; fType(0) = -4: fData(0) = "&lt;Or"<br/>&nbsp;&nbsp;&nbsp; fType(1) = 8: fData(1) = "AA1"<br/>&nbsp;&nbsp;&nbsp; fType(2) = -4: fData(2) = "Or&gt;"</p><p>必须得用运算符前后夹住图层AA1,是这个意思吗</p>
页: [1]
查看完整版本: 选择集的and和or的应用.