Message 1 of 4
Select an object on a specific layout

Not applicable
12-13-2003
08:15 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having trouble trying to select a block on a specific paperspace layout.
I thought I had figured it out but the code won't select any blocks. I want
to retrieve a title block on the current layout only. Here is the function
I wrote:
Public Function GetTitleBlock(tsTitleBlockSS As AcadSelectionSet) As Boolean
Dim llTitleBlockFound As Boolean
Dim laDXFCode(3) As Integer
Dim laFilterValue(3) As Variant
On Error GoTo ErrorHandler
GetTitleBlock = True
'
' Get the title block.
'
Set tsTitleBlockSS = ThisDrawing.SelectionSets.Add("TBLK_SS")
If Not tsTitleBlockSS Is Nothing Then
laDXFCode(0) = -4
laFilterValue(0) = "
laDXFCode(1) = 410
laFilterValue(1) = ThisDrawing.ActiveLayout.Name
laDXFCode(2) = 2
laFilterValue(2) = "TBLO*"
laDXFCode(3) = -4
laFilterValue(3) = "and>"
tsTitleBlockSS.Select acSelectionSetAll, , , laDXFCode, laFilterValue
If tsTitleBlockSS.Count > 0 Then
Set gbTitleBlockRef = tsTitleBlockSS.Item(0)
If Not gbTitleBlockRef.HasAttributes Then
ShowErrorMessage "No attributes defined in the found title block. "
& _
"Please insert a CRA title block and try again.",
True
GetTitleBlock = False
End If
Else
ShowErrorMessage "Unable to find a CRA standard title block in the
current drawing. " & _
"Please insert a CRA title block and try again.",
True
GetTitleBlock = False
End If
Else
ShowErrorMessage "Unable to create selection set possibly due to low
memory " & _
"or resources. Please close some applications and try
again.", True
GetTitleBlock = False
End If
Exit Function
ErrorHandler:
ShowErrorMessage Err.Description, True
GetTitleBlock = False
End Function
According to AutoDesk's DXF online reference, code 410 is the one for
layouts. All our title blocks here at work (CRA) are named starting with
the string TBLO. When I run this code from my routine in a drawing that has
two paperspace layouts and a title block on each, tsTitleBlockSS.Count
always returns 0.
Any help or suggestions would be greatly appreciated.
Stephen Fletcher
I thought I had figured it out but the code won't select any blocks. I want
to retrieve a title block on the current layout only. Here is the function
I wrote:
Public Function GetTitleBlock(tsTitleBlockSS As AcadSelectionSet) As Boolean
Dim llTitleBlockFound As Boolean
Dim laDXFCode(3) As Integer
Dim laFilterValue(3) As Variant
On Error GoTo ErrorHandler
GetTitleBlock = True
'
' Get the title block.
'
Set tsTitleBlockSS = ThisDrawing.SelectionSets.Add("TBLK_SS")
If Not tsTitleBlockSS Is Nothing Then
laDXFCode(0) = -4
laFilterValue(0) = "
laFilterValue(1) = ThisDrawing.ActiveLayout.Name
laDXFCode(2) = 2
laFilterValue(2) = "TBLO*"
laDXFCode(3) = -4
laFilterValue(3) = "and>"
tsTitleBlockSS.Select acSelectionSetAll, , , laDXFCode, laFilterValue
If tsTitleBlockSS.Count > 0 Then
Set gbTitleBlockRef = tsTitleBlockSS.Item(0)
If Not gbTitleBlockRef.HasAttributes Then
ShowErrorMessage "No attributes defined in the found title block. "
& _
"Please insert a CRA title block and try again.",
True
GetTitleBlock = False
End If
Else
ShowErrorMessage "Unable to find a CRA standard title block in the
current drawing. " & _
"Please insert a CRA title block and try again.",
True
GetTitleBlock = False
End If
Else
ShowErrorMessage "Unable to create selection set possibly due to low
memory " & _
"or resources. Please close some applications and try
again.", True
GetTitleBlock = False
End If
Exit Function
ErrorHandler:
ShowErrorMessage Err.Description, True
GetTitleBlock = False
End Function
According to AutoDesk's DXF online reference, code 410 is the one for
layouts. All our title blocks here at work (CRA) are named starting with
the string TBLO. When I run this code from my routine in a drawing that has
two paperspace layouts and a title block on each, tsTitleBlockSS.Count
always returns 0.
Any help or suggestions would be greatly appreciated.
Stephen Fletcher