Selecting objects on current layout

Selecting objects on current layout

Anonymous
Not applicable
285 Views
3 Replies
Message 1 of 4

Selecting objects on current layout

Anonymous
Not applicable
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
0 Likes
286 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
You can easily filter by layout by just using
the ObjectID of the Block associated with the
desired layout:

Dim idBlock As Long
idBlock = ThisDrawing.ActiveLayout.Block.ObjectId

For i = 0 to sset.Count - 1
If sset(i).OwnerId = idBlock Then
retval.Add(sset(i))
End If
Next i

"corsoc" wrote in message news:f12aab1.-1@WebX.maYIadrTaRb...
> 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
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
tony,

could you not also do it in this fashion?

dim x as integer
dim obj as acadentity

For x = 0 To ThisDrawing.ActiveLayout.block.Count - 1
set obj = ThisDrawing.ActiveLayout.block.item(x)
next x


"Tony Tanzillo" wrote in message
news:4D4DBEB0EB4D917FC7148EA78F4672F5@in.WebX.maYIadrTaRb...
> You can easily filter by layout by just using
> the ObjectID of the Block associated with the
> desired layout:
>
> Dim idBlock As Long
> idBlock = ThisDrawing.ActiveLayout.Block.ObjectId
>
> For i = 0 to sset.Count - 1
> If sset(i).OwnerId = idBlock Then
> retval.Add(sset(i))
> End If
> Next i
>
> "corsoc" wrote in message
news:f12aab1.-1@WebX.maYIadrTaRb...
> > 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
> >
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
"Tom Furness" wrote in message news:585F7E231B822329DA0F988D13FE5468@in.WebX.maYIadrTaRb...
> tony,
>
> could you not also do it in this fashion?
>
> dim x as integer
> dim obj as acadentity
>
> For x = 0 To ThisDrawing.ActiveLayout.block.Count - 1
> set obj = ThisDrawing.ActiveLayout.block.item(x)
> next x

Yes.
0 Likes