Author Topic: Viewport Modified event for scale  (Read 9209 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6144
Viewport Modified event for scale
« on: October 06, 2012, 03:49:19 AM »
If needing to modify an object when the scale(CustomScale/StandardScale property) changes and getting notified from Modified event the modified event is not invoked if changed through a activated viewport.
 
So if you double click inside a viewport then roll the middle mouse or use ZOOM command then the modified event is not fired.
 
 
Any ideas on how to handle this?

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #1 on: October 06, 2012, 01:49:21 PM »
You just pointed me towards MgdDbg in my other thread, and it appears to detect Editor Point Monitor Event, when you double click to activate PViewport, then scroll the mouse wheel:

Code - Auto/Visual Lisp: [Select]
  1. Command: _MgdDbgEvents
  2.  
  3. Application Events Turned On ...
  4.  
  5. Database Events Turned On ...
  6.  
  7. Database Object Events Turned On ...
  8.  
  9. Document Events Turned On ...
  10.  
  11. Editor Events Turned On ...
  12.  
  13. [Doc Event] : Command Ended             : MGDDBGEVENTS
  14. [Editor Event] : Entering Quiescent State
  15. [Editor Event] : Point Filter
  16. [Editor Event] : Point Monitor
  17. [Editor Event] : Point Filter
  18. [Editor Event] : Point Monitor
  19. [Editor Event] : Point Filter
  20. [Editor Event] : Point Monitor
  21. [Editor Event] : Point Filter
  22. [Editor Event] : Point Monitor
  23. [Editor Event] : Point Filter
  24. [Editor Event] : Point Monitor
  25. [Editor Event] : Point Filter
  26. [Editor Event] : Point Monitor
  27. [Editor Event] : Point Filter
  28. [Editor Event] : Point Monitor
  29. [Editor Event] : Point Filter
  30. [Editor Event] : Point Monitor
  31. [Editor Event] : Point Filter
  32. [Editor Event] : Point Monitor
  33. [Editor Event] : Point Filter
  34. [Editor Event] : Point Monitor
  35. [Editor Event] : Point Filter
  36. [Editor Event] : Point Monitor
  37. [Editor Event] : Leaving Quiescent State
  38. [Editor Event] : Prompting For Corner Specify opposite corner:
  39. [Editor Event] : Prompting For Point
  40. [App Event] : System Var Changing       : DYNMODE
  41. [App Event] : System Var Changed        : DYNMODE
  42. [App Event] : System Var Changing       : DYNMODE
  43. [App Event] : System Var Changed        : DYNMODE
  44. [Editor Event] : Point Filter
  45. [Editor Event] : Point Monitor
  46. [Editor Event] : Prompting For Selection
  47. [Editor Event] : Selection Added
  48. [Editor Event] : Prompt For Selection Ending
  49. [Editor Event] : Prompted For Selection
  50. [Editor Event] : Prompting For Selection
  51. [Editor Event] : Selection Added
  52. [Editor Event] : Prompt For Selection Ending
  53. [Editor Event] : Prompted For Selection *Cancel*
  54.  
  55. [Editor Event] : Prompted For Point
  56. [Editor Event] : Prompted For Corner
  57. [Editor Event] : Entering Quiescent State
  58. [Editor Event] : Point Filter
  59. [Editor Event] : Point Monitor        _
  60. [Editor Event] : Point Filter         _
  61. [Editor Event] : Point Monitor        _.
  62. [Editor Event] : Point Filter         _.
  63. [Editor Event] : Point Monitor        _.M
  64. [Editor Event] : Point Filter         _.M
  65. [Editor Event] : Point Monitor        _.MS
  66. [Editor Event] : Point Filter         _.MS
  67. [Editor Event] : Point Monitor        _.MSP
  68. [Editor Event] : Point Filter         _.MSP
  69. [Editor Event] : Point Monitor        _.MSPA
  70. [Editor Event] : Point Filter         _.MSPA
  71. [Editor Event] : Point Monitor        _.MSPAC
  72. [Editor Event] : Point Filter         _.MSPAC
  73. [Editor Event] : Point Monitor        _.MSPACE
  74. [Editor Event] : Point Filter         _.MSPACE
  75. [Editor Event] : Point Monitor        _.MSPACE
  76. [Editor Event] : Leaving Quiescent State
  77. [Doc Event] : Command will Start        : MSPACE
  78. [App Event] : System Var Changing       : CVPORT
  79. [App Event] : System Var Changed        : CVPORT
  80. [Doc Event] : Command Ended             : MSPACE
  81. [App Event] : System Var Changing       : UCSNAME
  82. [App Event] : System Var Changed        : UCSNAME
  83. [Editor Event] : Entering Quiescent State
  84. [Editor Event] : Point Filter
  85. [Editor Event] : Point Monitor
  86. [Editor Event] : Point Filter
  87. [Editor Event] : Point Monitor
  88. [Editor Event] : Point Filter
  89. [Editor Event] : Point Monitor
  90. [Editor Event] : Point Filter
  91. [Editor Event] : Point Monitor
  92. [Editor Event] : Point Filter
  93. [Editor Event] : Point Monitor
  94. [Editor Event] : Point Filter
  95. [Editor Event] : Point Monitor
  96. [Editor Event] : Point Filter
  97. [Editor Event] : Point Monitor
  98. [Editor Event] : Point Filter
  99.  

My only other thought (and I have no idea of actually how to accomplish this), is to hook the MouseWheel Event, which would still require some trigger to enable/disable so as to not monitor this event all the time... Perhaps use CommandEnded Event to test for MSPACE/PSPACE to enable/disable the MouseWheel Event handler respectively?

HTH
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #2 on: October 07, 2012, 11:40:40 PM »
If needing to modify an object when the scale(CustomScale/StandardScale property) changes and getting notified from Modified event the modified event is not invoked if changed through a activated viewport.
 
So if you double click inside a viewport then roll the middle mouse or use ZOOM command then the modified event is not fired.
 
 
Any ideas on how to handle this?

The Modified event of what object? The viewport ?


Jeff H

  • Needs a day job
  • Posts: 6144
Re: Viewport Modified event for scale
« Reply #3 on: October 07, 2012, 11:47:05 PM »
Yes sir.
 
The floating viewport in paperspace.

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #4 on: October 09, 2012, 12:35:41 AM »
Yes sir.
 
The floating viewport in paperspace.

Have you tried the Document's ViewChanged event ?

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #5 on: October 09, 2012, 10:39:44 AM »
Yes sir.
 
The floating viewport in paperspace.

Have you tried the Document's ViewChanged event ?

FWIW using MgdDbg -

Code - Auto/Visual Lisp: [Select]
  1. Command: _MgdDbgEvents
  2.  
  3. Document Events Turned On ...
  4.  
  5. [Doc Event] : Command Ended             : MGDDBGEVENTS
  6.  
  7. Command: zoom
  8.  
  9. [Doc Event] : Command will Start        : ZOOM
  10. Specify corner of window, enter a scale factor (nX or nXP), or
  11. [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: s
  12.  
  13. Enter a scale factor (nX or nXP): 1/20xp
  14.  
  15. [Doc Event] : Command Ended             : ZOOM
  16.  
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #6 on: October 09, 2012, 10:51:55 AM »
Taking a peek at DB Object Events, I manually selected the PViewport, and changed the Annotation Scale....

Code - Auto/Visual Lisp: [Select]
  1. Command: _MgdDbgEvents
  2.  
  3. [Doc Event] : Command will Start        : MGDDBGEVENTS
  4. Database Events Turned On ...
  5.  
  6. Database Object Events Turned On ...
  7.  
  8. Graphics System Events Turned On ...
  9.  
  10. [Doc Event] : Command Ended             : MGDDBGEVENTS
  11. [Doc Event] : Implied Selection Changed
  12. [DB Event : 1744478096] : Object Opened For Modify  : <Viewport, 1003C>
  13. [DB Event : 1744478096] : Object Modified           : <DBDictionary, 1003D>
  14. [DB Event : 1744478096] : Object Opened For Modify  : <Xrecord, 1003E>
  15. [DB Event : 1744478096] : Object Modified           : <Xrecord, 1003E>
  16. [DB Event : 1744478096] : Object Modified           : <DBDictionary, 1003D>
  17. [DB Event : 1744478096] : Object Modified           : <Viewport, 1003C>
  18. [DB Event : 1744478096] : Object Opened For Modify  : <Viewport, 1003C>
  19. [DB Event : 1744478096] : Object Modified           : <Viewport, 1003C>
  20.  
"How we think determines what we do, and what we do determines what we get."

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Viewport Modified event for scale
« Reply #7 on: October 09, 2012, 02:02:30 PM »
LOL, see you give RenderMan a new toy/tool and he is using the hell out of it.  Good work RM!
Revit 2019, AMEP 2019 64bit Win 10

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #8 on: October 09, 2012, 02:27:15 PM »
LOL, see you give RenderMan a new toy/tool and he is using the hell out of it.  Good work RM!

 :-D Cheers, dude!
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #9 on: October 09, 2012, 06:02:51 PM »
Yes sir.
 
The floating viewport in paperspace.

Have you tried the Document's ViewChanged event ?

FWIW using MgdDbg -

Code - Auto/Visual Lisp: [Select]
  1. Command: _MgdDbgEvents
  2.  
  3. Document Events Turned On ...
  4.  
  5. [Doc Event] : Command Ended             : MGDDBGEVENTS
  6.  
  7. Command: zoom
  8.  
  9. [Doc Event] : Command will Start        : ZOOM
  10. Specify corner of window, enter a scale factor (nX or nXP), or
  11. [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: s
  12.  
  13. Enter a scale factor (nX or nXP): 1/20xp
  14.  
  15. [Doc Event] : Command Ended             : ZOOM
  16.  


MgdDbg doesn't know about the ViewChanged event because it was written before the event was added to the API.

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #10 on: October 09, 2012, 06:05:35 PM »
Yes sir.
 
The floating viewport in paperspace.

Have you tried the Document's ViewChanged event ?

FWIW using MgdDbg -

Code - Auto/Visual Lisp: [Select]
  1. Command: _MgdDbgEvents
  2.  
  3. Document Events Turned On ...
  4.  
  5. [Doc Event] : Command Ended             : MGDDBGEVENTS
  6.  
  7. Command: zoom
  8.  
  9. [Doc Event] : Command will Start        : ZOOM
  10. Specify corner of window, enter a scale factor (nX or nXP), or
  11. [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: s
  12.  
  13. Enter a scale factor (nX or nXP): 1/20xp
  14.  
  15. [Doc Event] : Command Ended             : ZOOM
  16.  


MgdDbg doesn't know about the ViewChanged event because it was written before the event was added to the API.

Thanks for educating me, Tony; I searched Object Browser, and there it was (Oops!).

"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6144
Re: Viewport Modified event for scale
« Reply #11 on: October 09, 2012, 06:15:20 PM »
Thank you Tony,
 
I updated MgdDbg and here she went
Quote

Document Events Turned On ...
[Doc Event] : Command Ended             : MGDDBGEVENTS
Command: Specify opposite corner or [Fence/WPolygon/CPolygon]: *Cancel*
Command: _.MSPACE
[Doc Event] : Command will Start        : MSPACE
[Doc Event] : Command Ended             : MSPACE
Command:
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed
[Doc Event] : View Changed             _.PSPACE
[Doc Event] : Command will Start        : PSPACE
[Doc Event] : Command Ended             : PSPACE

I remeber Tony had a Database Explorer tool that wish I could get my hands on.
That would be a tool worth paying for.

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #12 on: October 09, 2012, 08:15:47 PM »
How does one update MgdDbg, as it is not included with ObjectARX SDK like its brother ArxDbg, despite being coded in C++...?

I did get the source when downloading the App from the DevTech link in my othe thread; just curious.
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #13 on: October 10, 2012, 01:26:55 AM »
How does one update MgdDbg, as it is not included with ObjectARX SDK like its brother ArxDbg, despite being coded in C++...?

I did get the source when downloading the App from the DevTech link in my othe thread; just curious.

It's not coded in C++, it's coded in C#.

And, If the author(s) had done it correctly, there would be no need to update it to support new events, just as there's no need to update it to support properties that are displayed in a property grid.

However, they took a very different approach and a really bad one at that, which is that rather than using a dynamic approach (like that used with Reflection in .NET), they hard-coded everything.

IOW, just as you can use reflection to discover what properties an object supports dynamically at runtime, you can do the same with events, and you can add handlers to them as well.

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #14 on: October 10, 2012, 01:49:32 AM »
How does one update MgdDbg, as it is not included with ObjectARX SDK like its brother ArxDbg, despite being coded in C++...?

I did get the source when downloading the App from the DevTech link in my othe thread; just curious.

PS:

I took a look at the notifications for the CVPORT sysvar, and it looks like that notification is badly broken. When switching from the model layout to a paper layout, it doesn't fire. When switching from a paper layout to the model layout, it fires twice, and I wouldn't count on that ever getting fixed.

This code will notify you when any of the following happens:
 
   1.  The active layout was switched
   2.  The active viewport was switched
   3.  The active viewport has changed (e.g., zoom/pan)

Code - C#: [Select]
  1.  
  2. // Shows how to get notified when the current viewport changes,
  3. // including when switching between paper/model space and between
  4. // layouts.
  5.  
  6. public class UIBindingsNotificationExample
  7. {
  8.    public UIBindingsNotificationExample()
  9.    {
  10.       INotifyPropertyChanged source = Application.UIBindings.CurrentViewport as INotifyPropertyChanged;
  11.       source.PropertyChanged += this.currentViewportChanged;
  12.    }
  13.    
  14.    void currentViewportChanged( object sender, PropertyChangedEventArgs e )
  15.    {
  16.       Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(
  17.          "\n*** Current viewport changed: {0}",
  18.          Application.GetSystemVariable( "CVPORT" )
  19.       );
  20.    }
  21.    
  22. }
  23.  

Using the above, you can ditch handling of both the LayoutSwitched event,
as well as the ViewChanged event.
« Last Edit: October 10, 2012, 02:22:31 AM by ADNGhostWriter »