ObjectErased event question

Anonymous

ObjectErased event question

Anonymous
Not applicable
All,

I have a polyline with xdata attached to it. The xdata contains three
handles to other objects. In the ObjectErased event, I would like to
retrieve the xdata and delete the other three objects as well.

However, in order to retrieve the xdata in ObjectErased, I need an
object, which no longer exists in the database. The ObjectErased Event
gives me an ObjectID. I tried ThisDrawing.ObjectIDtoObject but I
received an error (the object is already gone).

How should I handle this? Should I store the xdata elsewhere in another
object, or use a dictionary? Something/somewhere else?

Any ideas would be greatly appreciated. Thanks,

Danny Polkinhorn
Perkins & Will
Atlanta
0 Likes
Reply
336 Views
5 Replies
Replies (5)

Anonymous
Not applicable
I had the same problem. My solution was to store the ObjectID's of all related objects in
a collection. Then I could check the ObjectID in the Object_Erased event to see if it was
a member of the collection. If so, the ObjectID's of its companion objects are also in
the collection. I had only two objects to deal with (a text object and a wipeout object),
so parsing the list wasn't too difficult. I would imagine you would need something a bit
more structured for a larger number of objects. A dictionary sounds better suited to the
task.

I am sure this is not the most elegant approach, but it worked. I would certainly be
interested in hearing other ideas.

Chuck


"Danny P." wrote in message
news:3BF52A97.8020206@nspam.perkinswill.com...
> All,
>
> I have a polyline with xdata attached to it. The xdata contains three
> handles to other objects. In the ObjectErased event, I would like to
> retrieve the xdata and delete the other three objects as well.
>
> However, in order to retrieve the xdata in ObjectErased, I need an
> object, which no longer exists in the database. The ObjectErased Event
> gives me an ObjectID. I tried ThisDrawing.ObjectIDtoObject but I
> received an error (the object is already gone).
>
> How should I handle this? Should I store the xdata elsewhere in another
> object, or use a dictionary? Something/somewhere else?
>
> Any ideas would be greatly appreciated. Thanks,
>
> Danny Polkinhorn
> Perkins & Will
> Atlanta
>
0 Likes

Anonymous
Not applicable
Danny, Chuck,

You both are trying to solve the problem the classic problem of object
relationships, and keeping them in sync. It's pretty hard to do with VBA.
With ObjectARX, you could solve part of the problem because you can open up
"erased" objects for reading. However, you are really just scratching the
surface of the problem. What happens on Undo/Redo, Copy, Copy Clip, etc?

If you are using Architectural Desktop, this problem is addressed with
"Anchors". Anchors allow AEC objects to be attached to any AutoCAD entity.
The anchors can constrain movement, or just provide a link between the
objects. In Danny's case, a MultiView Block object, (user defined graphics)
could be anchored to a polyline object. If the object is erased, the MVBlock
is erased as well. If "Undo" happens, the MVBlock is un-erased as well and
re attached to the polyline.

Again, this is a very hard problem to solve completely.

Cheers,

Peter Funk
API Product Manager
Building Industry Division
Autodesk, Inc.
0 Likes

Anonymous
Not applicable
Peter/Chuck,

Thanks for replying.

Peter, as you know, we are using ADT so I'll look into the anchoring
process. You're right, I do have to worry about undos, etc. If
anchoring takes care of that for me, it sounds like it'll be a better route.

Can I access the attributes in the Multi-view block just like I can with
a standard block? I took a quick peek at the Object Browser, and I
don't see anything which would indicate that I could.

Thanks again,
Danny

Peter Funk - Autodesk, Inc wrote:

> Danny, Chuck,
>
> You both are trying to solve the problem the classic problem of object
> relationships, and keeping them in sync. It's pretty hard to do with VBA.
> With ObjectARX, you could solve part of the problem because you can open up
> "erased" objects for reading. However, you are really just scratching the
> surface of the problem. What happens on Undo/Redo, Copy, Copy Clip, etc?
>
> If you are using Architectural Desktop, this problem is addressed with
> "Anchors". Anchors allow AEC objects to be attached to any AutoCAD entity.
> The anchors can constrain movement, or just provide a link between the
> objects. In Danny's case, a MultiView Block object, (user defined graphics)
> could be anchored to a polyline object. If the object is erased, the MVBlock
> is erased as well. If "Undo" happens, the MVBlock is un-erased as well and
> re attached to the polyline.
>
> Again, this is a very hard problem to solve completely.
>
> Cheers,
>
> Peter Funk
> API Product Manager
> Building Industry Division
> Autodesk, Inc.
>
>
>
0 Likes

Anonymous
Not applicable
Danny,

The attributes that display in a MVBlock generally get their text from a
property set, therefore to change the attribute you would change the
property data. As you know, property data can be placed on any AutoCAD
entity, including polylines. The definition of the attribute (font, size
etc) is set in the underlying block that is used in the MVBlock.

Let me know what you are trying to do, and I'll give you a more targeted
answer.

Cheers,

Peter Funk
API Product Manager
Building Industry Division
Autodesk, Inc.


"Danny P." wrote in message
news:3BF55EB4.1030402@nspam.perkinswill.com...
> Peter/Chuck,
>
> Thanks for replying.
>
> Peter, as you know, we are using ADT so I'll look into the anchoring
> process. You're right, I do have to worry about undos, etc. If
> anchoring takes care of that for me, it sounds like it'll be a better
route.
>
> Can I access the attributes in the Multi-view block just like I can with
> a standard block? I took a quick peek at the Object Browser, and I
> don't see anything which would indicate that I could.
>
> Thanks again,
> Danny
>
> Peter Funk - Autodesk, Inc wrote:
>
> > Danny, Chuck,
> >
> > You both are trying to solve the problem the classic problem of object
> > relationships, and keeping them in sync. It's pretty hard to do with
VBA.
> > With ObjectARX, you could solve part of the problem because you can open
up
> > "erased" objects for reading. However, you are really just scratching
the
> > surface of the problem. What happens on Undo/Redo, Copy, Copy Clip, etc?
> >
> > If you are using Architectural Desktop, this problem is addressed with
> > "Anchors". Anchors allow AEC objects to be attached to any AutoCAD
entity.
> > The anchors can constrain movement, or just provide a link between the
> > objects. In Danny's case, a MultiView Block object, (user defined
graphics)
> > could be anchored to a polyline object. If the object is erased, the
MVBlock
> > is erased as well. If "Undo" happens, the MVBlock is un-erased as well
and
> > re attached to the polyline.
> >
> > Again, this is a very hard problem to solve completely.
> >
> > Cheers,
> >
> > Peter Funk
> > API Product Manager
> > Building Industry Division
> > Autodesk, Inc.
> >
> >
> >
>
0 Likes

Anonymous
Not applicable
Peter,

Thanks for taking my simple project and making really complicated!
Since this is ADT related, I'm moving to the other newsgroup.

-Danny

Peter Funk - Autodesk, Inc wrote:

> Danny,
>
> The attributes that display in a MVBlock generally get their text from a
> property set, therefore to change the attribute you would change the
> property data. As you know, property data can be placed on any AutoCAD
> entity, including polylines. The definition of the attribute (font, size
> etc) is set in the underlying block that is used in the MVBlock.
>
> Let me know what you are trying to do, and I'll give you a more targeted
> answer.
>
> Cheers,
>
> Peter Funk
> API Product Manager
> Building Industry Division
> Autodesk, Inc.
>
>
> "Danny P." wrote in message
> news:3BF55EB4.1030402@nspam.perkinswill.com...
>
>>Peter/Chuck,
>>
>>Thanks for replying.
>>
>>Peter, as you know, we are using ADT so I'll look into the anchoring
>>process. You're right, I do have to worry about undos, etc. If
>>anchoring takes care of that for me, it sounds like it'll be a better
>>
> route.
>
>>Can I access the attributes in the Multi-view block just like I can with
>>a standard block? I took a quick peek at the Object Browser, and I
>>don't see anything which would indicate that I could.
>>
>>Thanks again,
>>Danny
>>
>>Peter Funk - Autodesk, Inc wrote:
>>
>>
>>>Danny, Chuck,
>>>
>>>You both are trying to solve the problem the classic problem of object
>>>relationships, and keeping them in sync. It's pretty hard to do with
>>>
> VBA.
>
>>>With ObjectARX, you could solve part of the problem because you can open
>>>
> up
>
>>>"erased" objects for reading. However, you are really just scratching
>>>
> the
>
>>>surface of the problem. What happens on Undo/Redo, Copy, Copy Clip, etc?
>>>
>>>If you are using Architectural Desktop, this problem is addressed with
>>>"Anchors". Anchors allow AEC objects to be attached to any AutoCAD
>>>
> entity.
>
>>>The anchors can constrain movement, or just provide a link between the
>>>objects. In Danny's case, a MultiView Block object, (user defined
>>>
> graphics)
>
>>>could be anchored to a polyline object. If the object is erased, the
>>>
> MVBlock
>
>>>is erased as well. If "Undo" happens, the MVBlock is un-erased as well
>>>
> and
>
>>>re attached to the polyline.
>>>
>>>Again, this is a very hard problem to solve completely.
>>>
>>>Cheers,
>>>
>>>Peter Funk
>>>API Product Manager
>>>Building Industry Division
>>>Autodesk, Inc.
>>>
>>>
>>>
>>>
>
>
0 Likes