.NET

Reply
Active Member
maccip
Posts: 10
Registered: ‎02-24-2006
Message 1 of 8 (278 Views)
Accepted Solution

CommandEnded doesn't fire after Proprerty modified in Proprieties window

278 Views, 7 Replies
02-18-2013 02:41 AM

I'm a beginer in programming Autocad and my english may not be so good.

I'm trying to modify a table after user modifies a cell of that table. So i'm using CommandEnded event to do so.

The program works fine until user change table cell content via Proprieties Window. That because CommandEnded doesnt fire in that case.

I cannot use Table object's events because i have to modify the Table object itself during that notification (eWasNotifying error).

There is a trick to manage this problem?

Alex - The controls on the Ribbon do not filre the ModelessOperationWillStart/Ended() notifications either, so that entire approach is flawed to begin with.

 

The ModelessOperationWillStart/Ended() notifications are effectively-obsolete, and the fact that they're not exposed to managed code isn't a major issue, because you can just as easily use the DocumentLockModeWillChange event of the DocumentCollection to do effectively the same thing (when the document is unlocked, that corresponds to the ModelessOperationEnded() notification).

 

The problem with using the ModelessOperationEnded() notification to make additional changes, is that those additional changes are not encapsulated within the same UNDO groujp/transaction as the changes that triggered the notification, and to the end user, all of the changes are part of a single, logical operation that should be undo-able as a group. Unfortunately, changes made in reaction to changes that trigger a ModelessOperationEnded() notification, will not be undone along with the original changes that triggered the notification. So, if the user issues UNDO/1 after you've made additional changes in response to ModelessOperationEnded(), only those additional changes will be undone, but not the changes that triggered them, and that is a problem.

 

The best possible way to deal with problems like this, is to use an ObjectOverrule, provided it is constrained using some kind of Filter (ObjectId filter, XData filter or XDictionary filter). Unlike the ObjectModified event of the Database, within the Close() override of the ObjectOverrule, the notifying object that is about to be closed can be modified, and more-importantly, any additional changes made at that point will be undone along with all other changes made prior to that, by whatever operation made them.  

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 2 of 8 (264 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 04:08 AM in reply to: maccip

How to know if an entity's properties are modified by the OPM?

But that possible with ObjectARX and not with AutoCAD .NET API:

Can't find ModelessOperationWill Start Event in .NET

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 8 (247 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 05:25 AM in reply to: maccip

You may want to see this post for more

http://www.theswamp.org/index.php?topic=43757.msg491198#msg491198

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 4 of 8 (241 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 07:26 AM in reply to: Hallex

Hallex wrote:

You may want to see this post for more

http://www.theswamp.org/index.php?topic=43757.msg491198#msg491198


Sorry, but the link above does not help the author to solve his problem. The reason is that the event CommanEnded does not occur when editing primitives through the Properties panel.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Member
maccip
Posts: 10
Registered: ‎02-24-2006
Message 5 of 8 (235 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 08:32 AM in reply to: Alexander.Rivilis

Thanks Alexander.

At the first look the solution looks a little complicated for me. At least I know that is about reacting to OPM events. For now i want to keep my code simple, so i will not complicate responding to OPM events. After i will finish the project, i will consider to upgrade my code with OPM events. Until then i will instruct users of my plugin to not use Proprieties Window to change the table.

I was hoping to be more simple (like an allready exposed .NET event) because i'm learning best practices to handle .NET events. Do you know a resource to learn more about .NET events or best practices?

Sory for my bad english, and thanks!

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 6 of 8 (210 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 10:36 PM in reply to: Alexander.Rivilis

Alex - The controls on the Ribbon do not filre the ModelessOperationWillStart/Ended() notifications either, so that entire approach is flawed to begin with.

 

The ModelessOperationWillStart/Ended() notifications are effectively-obsolete, and the fact that they're not exposed to managed code isn't a major issue, because you can just as easily use the DocumentLockModeWillChange event of the DocumentCollection to do effectively the same thing (when the document is unlocked, that corresponds to the ModelessOperationEnded() notification).

 

The problem with using the ModelessOperationEnded() notification to make additional changes, is that those additional changes are not encapsulated within the same UNDO groujp/transaction as the changes that triggered the notification, and to the end user, all of the changes are part of a single, logical operation that should be undo-able as a group. Unfortunately, changes made in reaction to changes that trigger a ModelessOperationEnded() notification, will not be undone along with the original changes that triggered the notification. So, if the user issues UNDO/1 after you've made additional changes in response to ModelessOperationEnded(), only those additional changes will be undone, but not the changes that triggered them, and that is a problem.

 

The best possible way to deal with problems like this, is to use an ObjectOverrule, provided it is constrained using some kind of Filter (ObjectId filter, XData filter or XDictionary filter). Unlike the ObjectModified event of the Database, within the Close() override of the ObjectOverrule, the notifying object that is about to be closed can be modified, and more-importantly, any additional changes made at that point will be undone along with all other changes made prior to that, by whatever operation made them.  

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 7 of 8 (209 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-18-2013 10:41 PM in reply to: maccip

See my reply to Alex regarding this issue. The entire approach you want to take has some problems.

 

Secondly, you really don't want to find yourself in the position where you find it necessary to tell users they can't use certain tools, like the Properties palette or the ribbon.

  

 

Moderator
Alexander.Rivilis
Posts: 1,417
Registered: ‎04-09-2008
Message 8 of 8 (200 Views)

Re: CommandEnded doesn't fire after Proprerty modified in Proprieties window

02-19-2013 12:20 AM in reply to: DiningPhilosopher

Tony! Thank you for the excellent explanation. What a pity that you so long was not on the Autodesk forum ...


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.