> ssn
Чтоб ты долго не мучался, посмотри два примера:
Option Explicit
Public Sub GetSelectionInLayout(oSset As AcadSelectionSet, layoutName As String)
' by Fatty T.O.H () 2007 * all rights removed
Dim oLayout As AcadLayout, _
i As Integer, _
j As Integer, _
oID As Long, _
objArray() As AcadEntity
Set oLayout = ThisDrawing.Layouts(layoutName)
oID = oLayout.Block.ObjectID
For i = 0 To oSset.Count - 1
If oSset.Item(i).OwnerID <> oID Then
ReDim Preserve objArray(j)
Set objArray(j) = oSset.Item(i)
j = j + 1
End If
Next
oSset.RemoveItems objArray
End Sub
''~~~~~~~~select multilines in the particular layout~~~~~~~''
Sub test1()
Dim oSset As AcadSelectionSet
Dim setName As String, i As Integer
Dim laytName As String
Dim dxfcode(0 To 1) As Integer
Dim dxfdata(0 To 1) As Variant
dxfcode(0) = 0
dxfdata(0) = "MLINE"
dxfcode(1) = 67
dxfdata(1) = 1
setName = "$Mlines$"
laytName = "Layout1"
'Make sure selection set does not exist
For i = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(i).Name = setName Then
ThisDrawing.SelectionSets.Item(i).Delete
Exit For
End If
Next i
Set oSset = ThisDrawing.SelectionSets.Add(setName)
oSset.Select acSelectionSetAll, , , dxfcode, dxfdata
MsgBox "There are in the paper space : " & oSset.Count & vbCr & _
"multilines selected"
GetSelectionInLayout oSset, laytName
MsgBox "There are : " & oSset.Count & " multilines" & vbCr & _
"selected in layout " & Chr(34) & laytName & Chr(34)
End Sub
''~~~~~~~~~~~select multilines in model space~~~~~~~~''
Sub test2()
Dim oSset As AcadSelectionSet
Dim setName As String, i As Integer
Dim dxfcode(0 To 1) As Integer
Dim dxfdata(0 To 1) As Variant
dxfcode(0) = 0
dxfdata(0) = "MLINE"
dxfcode(1) = 67
dxfdata(1) = 0
setName = "$Mlines$"
'Make sure selection set does not exist
For i = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(i).Name = setName Then
ThisDrawing.SelectionSets.Item(i).Delete
Exit For
End If
Next i
Set oSset = ThisDrawing.SelectionSets.Add(setName)
oSset.Select acSelectionSetAll, , , dxfcode, dxfdata
MsgBox "There are in the model space : " & oSset.Count & vbCr & _
"multilines selected"
End Sub
~'J'~