Your code is using a transaction to get a managed wrapper for a currently-open database object for which you already have a managed wrapper for (the DBObject passed into the event handler).
There's no need to use a transaction in that case because the DBObject that is passed into the event handler is already open (and most-likely in state that would not allow it to be modified in any way), so you can use that DBObject directly.
Your code is using a transaction to get a managed wrapper for a currently-open database object for which you already have a managed wrapper for (the DBObject passed into the event handler).
There's no need to use a transaction in that case because the DBObject that is passed into the event handler is already open (and most-likely in state that would not allow it to be modified in any way), so you can use that DBObject directly.
Thanks for the correction, Tony.
I was mistaken in thinking that the ObjectModified also implied that the ObjectClosed had occurred, and now better understand why you aptly suggested storing the ObjectId's for later action, but am unsure how to utilize that, given that no Command is being used.
I am attempting to hook the Database.ObjectModified Event, rather than manage adding an ObjectModified Event to each existing entity and all those appended to the Database thereafter.
... Is it possible to modify the Object via Database.ObjectModified, or need I register an entity level ObjectClosed Event handler during Database.ObjectModified (untested)?
Your code is using a transaction to get a managed wrapper for a currently-open database object for which you already have a managed wrapper for (the DBObject passed into the event handler).
There's no need to use a transaction in that case because the DBObject that is passed into the event handler is already open (and most-likely in state that would not allow it to be modified in any way), so you can use that DBObject directly.
Thanks for the correction, Tony.
I was mistaken in thinking that the ObjectModified also implied that the ObjectClosed had occurred, and now better understand why you aptly suggested storing the ObjectId's for later action, but am unsure how to utilize that, given that no Command is being used.
I am attempting to hook the Database.ObjectModified Event, rather than manage adding an ObjectModified Event to each existing entity and all those appended to the Database thereafter.
... Is it possible to modify the Object via Database.ObjectModified, or need I register an entity level ObjectClosed Event handler during Database.ObjectModified (untested)?
Hard to say, without seeing the larger picture. What is it you are trying to accomplish?
Your code is using a transaction to get a managed wrapper for a currently-open database object for which you already have a managed wrapper for (the DBObject passed into the event handler).
There's no need to use a transaction in that case because the DBObject that is passed into the event handler is already open (and most-likely in state that would not allow it to be modified in any way), so you can use that DBObject directly.
Thanks for the correction, Tony.
I was mistaken in thinking that the ObjectModified also implied that the ObjectClosed had occurred, and now better understand why you aptly suggested storing the ObjectId's for later action, but am unsure how to utilize that, given that no Command is being used.
I am attempting to hook the Database.ObjectModified Event, rather than manage adding an ObjectModified Event to each existing entity and all those appended to the Database thereafter.
... Is it possible to modify the Object via Database.ObjectModified, or need I register an entity level ObjectClosed Event handler during Database.ObjectModified (untested)?
Hard to say, without seeing the larger picture. What is it you are trying to accomplish?
Sorry for not being more clear in previous posts.
I'm toying with the idea of an 'AnnoAuto' plug-in that would (based on user-defined XML settings), automatically apply the desired annotation entity settings for each a Dimension, Leader, MText, MLeader, and Text entities, based upon the Layer these entities reside, or are placed upon.
For years I've used Command Reactors (Visual LISP) to automatically configure certain properties, current layer, etc. for me, and am now attempting to enhance that via .NET API features, and ease of gathering requirements via XML, etc..
Perhaps I can use the Database.ObjectModified event to store the ObjectIds then use the Database.ObjectClosed event to 'act' (without having looked in Object Browser, as I am on my iPhone at the moment).
As always, I appreciate you time and feedback to ask questions that make me think this through rather than just giving me the answer so to speak. Cheers! :beer:
void Database_ObjectAppended(object sender, ObjectEventArgs e)
{
if (e.DBObject.GetType().Name.Equals("Group"))
{
Module.GrpInfoTbl.Add(e.DBObject.ObjectId);
}
}
public class Module
{
private static ObjectIdCollection OIDColl = new ObjectIdCollection();
public static ObjectIdCollection GrpInfoTbl
{
get
{
return OIDColl;
}
}
public Module()
{
}
}
Perhaps I can use the Database.ObjectModified event to store the ObjectIds then use the Database.ObjectClosed event to 'act' (without having looked in Object Browser, as I am on my iPhone at the moment).
What I've used is to keep an ObjectIdCollection of modified Objects I need to act on, then do so when the Editor's EnteringQuiescentState event fires.
What I've used is to keep an ObjectIdCollection of modified Objects I need to act on, then do so when the Editor's EnteringQuiescentState event fires.
At least I was able to get in the correct vicinity on my own, thanks for the information, Jeff (as always) (http://www.cadtutor.net/forum/images/smilies/notworthy.gif)
I am still not following completely on why does it have to be changed during a modified event rather than doing it during insertion or creation.
Are you trying to keep people from modifying a entity or during modifying set all properties?
So I've been testing the EnteringQuiescentState approach, and while it works, it's still not 'instantaneous' when one manually makes changes via Properties Palette... There's a delay, until one hits Esc, or click, windows, etc..
I tried looking for alternative Events, and one that came to mind is when DocumentLockModeChangedEventArgs.CurrentMode == DocumentLockMode.NotLocked, but I suspect that there may be some issues with that.
First issue that comes to mind, is attempting to Lock the Document, as this would raise the DocumentLockModeChanged Event again... So I would need to set a bool Property or Field such that the leading if statement would first check for this before continuing... But that still leaves room for an eLockChangeInProgress Exception.
Does anyone have another suggestion(s), in order for me to manipulate the ObjectIds following Database.ObjectModified Event?
Trying to carry the methods used in LISP or VBA over to .NET might work in some cases, but usually introduces its own set of problems, and still suffers from the same limitations you had in the previous implementation.
From the Close() override of an ObjectOverrule, you can modify the object.
If someone here has access to it, feel free to post a copy of my Overrule sample that shows exactly how that can be done (I'd post it myself but it'll take some time for me to find the original that has long since been modified for publication elsewhere).
Attached is one of the samples (I don't know if this was included in the copy I distributed), which shows how to lock the layer of all block references.