马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [FONT=century gothic]
- How to setup selectionset filters for a block or layer?
- ID 19147
- Applies to: AutoCAD 2000
-
- This document is part of Layers Block Reference COM-ActiveX Interfaces Selecting Entities Selection Sets VBA
- Question
- How do I use a selection set filter to select a block with a particular name
- that is on a particular layer ?
- Answer
- The following sample code allows you to select blocks based on this criteria:
- 1. selectALayer() - create a selectionset with entities on "layer1"
- 2. selectABlock() - create a selectionset with a block insert "testBlock"
- 3. selectABlockOnALayer() - create a selectionset with a block insert
- "testBlock"
- on "layer1"
- Sub selectALayer()
- Dim sset As Object
-
- Set sset = ThisDrawing.SelectionSets.Add("TestSet1")
- Dim filterType As Variant
- Dim filterData As Variant
- Dim p1(0 To 2) As Double
- Dim p2(0 To 2) As Double
-
- Dim grpCode(0) As Integer
- grpCode(0) = 8
- filterType = grpCode
- Dim grpValue(0) As Variant
- grpValue(0) = "layer1"
- filterData = grpValue
-
- sset.Select acSelectionSetAll, p1, p2, filterType, filterData
-
- End Sub
- Sub selectABlock()
- Dim sset As Object
-
- Set sset = ThisDrawing.SelectionSets.Add("TestSet2")
- Dim filterType As Variant
- Dim filterData As Variant
- Dim p1(0 To 2) As Double
- Dim p2(0 To 2) As Double
-
- Dim grpCode(0) As Integer
- grpCode(0) = 2
- filterType = grpCode
- Dim grpValue(0) As Variant
- grpValue(0) = "testBlock"
- filterData = grpValue
-
- sset.Select acSelectionSetAll, p1, p2, filterType, filterData
- End Sub
- Sub selectABlockOnALayer()
- Dim sset As Object
-
- Set sset = ThisDrawing.SelectionSets.Add("TestSet3")
- Dim filterType As Variant
- Dim filterData As Variant
- Dim p1(0 To 2) As Double
- Dim p2(0 To 2) As Double
-
- Dim grpCode(0 To 1) As Integer
- grpCode(0) = 8
- grpCode(1) = 2
- filterType = grpCode
- Dim grpValue(0 To 1) As Variant
- grpValue(0) = "layer1"
- grpValue(1) = "testBlock"
- filterData = grpValue
-
- sset.Select acSelectionSetAll, p1, p2, filterType, filterData
- End Sub[/FONT]
|