Adding a item with it's ObjectID to a selection set.

Adding a item with it's ObjectID to a selection set.

Anonymous
Not applicable
203 Views
3 Replies
Message 1 of 4

Adding a item with it's ObjectID to a selection set.

Anonymous
Not applicable
I was trying to add an entity to a selection set. I'm hacking
up your CAO example so I have its ObjectID.

 


'***this is what have so far:
Dim pick As
AcadSelectionSet
With ThisDrawing.SelectionSets
    Do
While .Count > 0
       
.Item(0).Delete
    Loop
End With
Set pick =
ThisDrawing.SelectionSets.Add("omar")
pick.Clear
'**** code
from CAO
If linkSel Is Nothing Then
    MsgBox "No
link!"
    Exit Sub
End If

 

' Get selected link
Dim link As
CAO.link
Set link = linkSel.Item(SpinButtonLinkIndex.Value - 1)
If
link Is Nothing Then
    MsgBox "Unable to retrieve
this link"
    Exit Sub
End If

 

pick.AddItem link.objectId '<---- gives a
"Object does not support method" error

 

Is there a way to convert the linked entity’s ObjectID
into a format, which the selection set method will accept?
Or is the another
way to accomplish this?

 

 
0 Likes
204 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Omar. The AddItems method expects an array of AcadEntity even if it is
only a single object. If all you have is the ObjectID, convert it to an
object by using the ObjectIDToObject method then add the resulting object to
an array. Finally, feed the array to the AddItems method. BTW, I'm not
familiar with automating MAP so please bear with me but is a link a
selectable object? If not, you can't add it to your selection set.

--
Get free software and more at
http://msnhomepages.talkcity.com/protectionfault/foquendo

"Omar Melo" wrote in message
news:87mq72$i3511@adesknews2.autodesk.com...
I was trying to add an entity to a selection set. I'm hacking up your CAO
example so I have its ObjectID.

'***this is what have so far:
Dim pick As AcadSelectionSet
With ThisDrawing.SelectionSets
Do While .Count > 0
.Item(0).Delete
Loop
End With
Set pick = ThisDrawing.SelectionSets.Add("omar")
pick.Clear
'**** code from CAO
If linkSel Is Nothing Then
MsgBox "No link!"
Exit Sub
End If

' Get selected link
Dim link As CAO.link
Set link = linkSel.Item(SpinButtonLinkIndex.Value - 1)
If link Is Nothing Then
MsgBox "Unable to retrieve this link"
Exit Sub
End If

pick.AddItem link.objectId '<---- gives a "Object does not support
method" error

Is there a way to convert the linked entity's ObjectID into a format, which
the selection set method will accept?
Or is the another way to accomplish this?
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks for looking at my problem Frank

I continued messing with it and located something that would let me use the
ObjectID.

I replace bad code:

> pick.AddItem link.objectId '<---- gives a "Object does not support
>method" error

with

Dim tempObj As AcadObject
Set tempObj = ThisDrawing.ObjectIdToObject(link.objectID)

How can I now take the object and covert it to an array so it can be added
to a selection set?

Frank Oquendo wrote in message <87mqgp$i3e6@adesknews2.autodesk.com>...
>Hi Omar. The AddItems method expects an array of AcadEntity even if it is
>only a single object. If all you have is the ObjectID, convert it to an
>object by using the ObjectIDToObject method then add the resulting object
to
>an array. Finally, feed the array to the AddItems method. BTW, I'm not
>familiar with automating MAP so please bear with me but is a link a
>selectable object? If not, you can't add it to your selection set.
>
>--
>Get free software and more at
>http://msnhomepages.talkcity.com/protectionfault/foquendo
>
>
>"Omar Melo" wrote in message
>news:87mq72$i3511@adesknews2.autodesk.com...
>I was trying to add an entity to a selection set. I'm hacking up your CAO
>example so I have its ObjectID.
>
> '***this is what have so far:
> Dim pick As AcadSelectionSet
> With ThisDrawing.SelectionSets
> Do While .Count > 0
> .Item(0).Delete
> Loop
> End With
> Set pick = ThisDrawing.SelectionSets.Add("omar")
> pick.Clear
> '**** code from CAO
> If linkSel Is Nothing Then
> MsgBox "No link!"
> Exit Sub
> End If
>
> ' Get selected link
> Dim link As CAO.link
> Set link = linkSel.Item(SpinButtonLinkIndex.Value - 1)
> If link Is Nothing Then
> MsgBox "Unable to retrieve this link"
> Exit Sub
> End If
>
> pick.AddItem link.objectId '<---- gives a "Object does not support
>method" error
>
>Is there a way to convert the linked entity's ObjectID into a format, which
>the selection set method will accept?
>Or is the another way to accomplish this?
>
>
>
>
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Using the code from your most recent post, you would just need to add
something like this:

Dim objArray(0 to 0) As AcadEntity

Set objArray(0) = tempObj
pick.AddItems objArray

--
Get free software and more at:
http://msnhomepages.talkcity.com/protectionfault/foquendo

"Omar Melo" wrote in message
news:87n6ej$ke17@adesknews2.autodesk.com...
> Thanks for looking at my problem Frank
>
> I continued messing with it and located something that would let me use
the
> ObjectID.
>
> I replace bad code:
>
> > pick.AddItem link.objectId '<---- gives a "Object does not support
> >method" error
>
> with
>
> Dim tempObj As AcadObject
> Set tempObj = ThisDrawing.ObjectIdToObject(link.objectID)
>
> How can I now take the object and covert it to an array so it can be added
> to a selection set?
>
>
>
> Frank Oquendo wrote in message <87mqgp$i3e6@adesknews2.autodesk.com>...
> >Hi Omar. The AddItems method expects an array of AcadEntity even if it is
> >only a single object. If all you have is the ObjectID, convert it to an
> >object by using the ObjectIDToObject method then add the resulting object
> to
> >an array. Finally, feed the array to the AddItems method. BTW, I'm not
> >familiar with automating MAP so please bear with me but is a link a
> >selectable object? If not, you can't add it to your selection set.
> >
> >--
> >Get free software and more at
> >http://msnhomepages.talkcity.com/protectionfault/foquendo
> >
> >
> >"Omar Melo" wrote in message
> >news:87mq72$i3511@adesknews2.autodesk.com...
> >I was trying to add an entity to a selection set. I'm hacking up your CAO
> >example so I have its ObjectID.
> >
> > '***this is what have so far:
> > Dim pick As AcadSelectionSet
> > With ThisDrawing.SelectionSets
> > Do While .Count > 0
> > .Item(0).Delete
> > Loop
> > End With
> > Set pick = ThisDrawing.SelectionSets.Add("omar")
> > pick.Clear
> > '**** code from CAO
> > If linkSel Is Nothing Then
> > MsgBox "No link!"
> > Exit Sub
> > End If
> >
> > ' Get selected link
> > Dim link As CAO.link
> > Set link = linkSel.Item(SpinButtonLinkIndex.Value - 1)
> > If link Is Nothing Then
> > MsgBox "Unable to retrieve this link"
> > Exit Sub
> > End If
> >
> > pick.AddItem link.objectId '<---- gives a "Object does not support
> >method" error
> >
> >Is there a way to convert the linked entity's ObjectID into a format,
which
> >the selection set method will accept?
> >Or is the another way to accomplish this?
> >
> >
> >
> >
> >
>
>
0 Likes