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

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Viewport Modified event for scale
« Reply #15 on: October 10, 2012, 10:39:04 AM »
I wouldn't mind dying and coming back reincarnated as Tony.  I am just saying.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #16 on: October 10, 2012, 11:47:46 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#.

<snip>

Yes, of course - I had downloaded and extracted multiple files that day, and simply remembered the incorrect source-code language. Thanks for the correction.



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.

Fantastic.

This may also come in handy for my plight in another thread... Thank you, Tony. :beer:



I wouldn't mind dying and coming back reincarnated as Tony.  I am just saying.

... I'd just like to buy him a few pints of his favorite frosty brew. :lol:
"How we think determines what we do, and what we do determines what we get."

TheMaster

  • Guest
Re: Viewport Modified event for scale
« Reply #17 on: October 10, 2012, 04:01:30 PM »

Fantastic.

This may also come in handy for my plight in another thread... Thank you, Tony. :beer:


A clarification might be in order, which is that the event fires even when the current viewport hasn't changed. It fires when the current view and/or viewport has changed, which includes when the active layout or active documents are switched. So, in the handler you will most-likely have to do some work to sort out what has actually changed or triggered the event. The simplest way to go about it is by using a state machine-approach, that tracks things like the view center/height, the viewport id, the active layout and active document.


BlackBox

  • King Gator
  • Posts: 3770
Re: Viewport Modified event for scale
« Reply #18 on: October 10, 2012, 04:28:01 PM »
As always, I appreciate the clarification of context, Tony.
"How we think determines what we do, and what we do determines what we get."