Create Selectionset filtered by block name.

Create Selectionset filtered by block name.

sgrya1
Advocate Advocate
369 Views
4 Replies
Message 1 of 5

Create Selectionset filtered by block name.

sgrya1
Advocate
Advocate
Can anyone help me create a slectionset which only allows a specified block name to be added to the set?
0 Likes
370 Views
4 Replies
Replies (4)
Message 2 of 5

sgrya1
Advocate
Advocate
Think I've found it
http://discussion.autodesk.com/thread.jspa?messageID=403097
0 Likes
Message 3 of 5

gizmowiebe
Contributor
Contributor
If not you can maybe use this:

Function GetBlockByRefName(sBlkName As String) As AcadBlockReference

On Error Resume Next


Dim SS As AcadSelectionSet, BlkRef As AcadBlock
'Get the block:
Set BlkRef = ThisDrawing.Blocks.Item(sBlkName)
'Block doesn't exist exit
If Err Then Exit Function
Set SS = ThisDrawing.SelectionSets.Item("SS")
SS.Clear
If Err Then
Err.Clear
Set SS = ThisDrawing.SelectionSets.Add("SS")
End If

'select the blocks named "sBlkName"
Dim FType(0) As Integer, FData(0)
FType(0) = 0: FData(0) = "INSERT"
SS.Select acSelectionSetAll, , , FType, FData
'Now you've got a selection set of all blocks named "sBlkName"
If SS.Count = 0 Then Exit Function 'Block is unreferenced, so bail

'Return the first block in the SS:
Set GetBlockByRefName = SS.Item(0)
SS.Delete
Set BlkRef = Nothing
Set SS = Nothing


End Function
0 Likes
Message 4 of 5

Anonymous
Not applicable
just my 2c inline


wrote in message news:5982866@discussion.autodesk.com...
If not you can maybe use this:

Function GetBlockByRefName(sBlkName As String) As AcadBlockReference

'On Error Resume Next <-------ouch...get rid of this(no On Error GoTo err
trap after this so no errors will be detected...very bad)

'Get the block:
'Set BlkRef = ThisDrawing.Blocks.Item(sBlkName)
snip

'no need to see if def exists, since you're only interested in inserts




'select the blocks named "sBlkName"
Dim FType(0) As Integer, FData(0)
FType(0) = 0: FData(0) = "INSERT"
SS.Select acSelectionSetAll, , , FType, FData
'Now you've got a selection set of all blocks named
"sBlkName"<-----------nope

'you have all inserts, not all inserts named sBlkName

'if you change the filter to FType(0) = 2: FData(0) = sBlkName
'then you'll have the inserts filtered by name

hth
mark
0 Likes
Message 5 of 5

Anonymous
Not applicable
Check this
Dim gCode1(1) As Integer
Dim dcode1(1) As Variant

gCode1(0) = 0
dcode1(0) = "INSERT"
gCode1(1) = 2
dcode1(1) = ur Block name
0 Likes