Message 1 of 4
Selecting objects on current layout

Not applicable
12-07-2002
05:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All,
I have written a function that selects all objects and filters them against the OwnerId property to determine that they relate to the current active layout and returns all true objects as a collection. The problem I am having is that the objects in other paper space layouts are being returned in the collection. It appears as that all objects in paperspace, regardless of the layout they are present in, are owned by paperspace.
Is there a way to determine what layout an object is really present in ?
Below is the code of my function :
Public Function get_CurrentLayoutObjects() As Collection
'function that gets all objects on active space and
'returns a collection
Dim retval As New Collection
Dim sset As AcadSelectionSet
Dim tempent As AcadEntity
Dim i As Long
On Error Resume Next
ThisDrawing.SelectionSets("temp").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("temp")
sset.Select acSelectionSetAll
'Set retval = sset2coll(sset)
For i = 0 To sset.Count - 1
Set tempent = sset.Item(i)
If LCase(ThisDrawing.ObjectIdToObject(tempent.OwnerID).Layout.Name) = _
LCase(ThisDrawing.ActiveLayout.Name) _
Then
retval.Add tempent
End If
Next i
Set get_CurrentLayoutObjects = retval
End Function
I have written a function that selects all objects and filters them against the OwnerId property to determine that they relate to the current active layout and returns all true objects as a collection. The problem I am having is that the objects in other paper space layouts are being returned in the collection. It appears as that all objects in paperspace, regardless of the layout they are present in, are owned by paperspace.
Is there a way to determine what layout an object is really present in ?
Below is the code of my function :
Public Function get_CurrentLayoutObjects() As Collection
'function that gets all objects on active space and
'returns a collection
Dim retval As New Collection
Dim sset As AcadSelectionSet
Dim tempent As AcadEntity
Dim i As Long
On Error Resume Next
ThisDrawing.SelectionSets("temp").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("temp")
sset.Select acSelectionSetAll
'Set retval = sset2coll(sset)
For i = 0 To sset.Count - 1
Set tempent = sset.Item(i)
If LCase(ThisDrawing.ObjectIdToObject(tempent.OwnerID).Layout.Name) = _
LCase(ThisDrawing.ActiveLayout.Name) _
Then
retval.Add tempent
End If
Next i
Set get_CurrentLayoutObjects = retval
End Function