How to tell if an ObjectID has already been Opened

How to tell if an ObjectID has already been Opened

Anonymous
Not applicable
984 Views
3 Replies
Message 1 of 4

How to tell if an ObjectID has already been Opened

Anonymous
Not applicable

I have an event handler setup for DB.ObjectErased event. In certain situations I need to check the object. However, I can run into an issue where the erase was triggered from another one of my functions, so I error out when I try to access the object with an eWasOpenForWrite.  The details are not very relevent here, and my question is: is there a way to check the object ID to see if it was already opened before I try to open it?

 

I would like to check, rather than put it in a Try...Catch, if only because when I debug, i leave visual studio set to break on exceptions and it can make debugging difficult when the code keeps stopping.

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

Anonymous
Not applicable

Database.ObjectErased provides the DBObject itself as an argument; you don't need to open it from an ObjectId.

 

-drg

0 Likes
Message 3 of 4

Anonymous
Not applicable

Check the property

 

DBObject.IsWriteEnabled
0 Likes
Message 4 of 4

Anonymous
Not applicable

Don't check DBObject.IsWriteEnabled in Database.ObjectErased.  Instead, check your assumptions about what triggers Database.ObjectErased and your assumption about what you can safely accomplish in Database.ObjectErased.

 

-drg

 

0 Likes