Catch Activating View(port) in a Sheet

Catch Activating View(port) in a Sheet

mdb
Contributor Contributor
692 Views
10 Replies
Message 1 of 11

Catch Activating View(port) in a Sheet

mdb
Contributor
Contributor

Hi,

To update my Dockable Pane to the correct View settings, I should be able to detect which View is active. This works well by capturing the ViewActivated Event, but I did notice that the Event (actually there is no event visible in the Lookup EventMonitor) is not triggered when the View is activated by entering a View(port) in a Sheet.

 

Is there another way to handle opening a view on a sheet?

0 Likes
693 Views
10 Replies
Replies (10)
Message 2 of 11

scgq425
Advocate
Advocate

Dear mdb

 u can use the iddleing event or documentchanged event to monitor this changed .

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 3 of 11

mdb
Contributor
Contributor

Unfortunately, the DocumentChanged Event does not notify you when a Viewport is activated.

I'm going to try it via the Idling Event.

Thanks for the tip!

0 Likes
Message 4 of 11

scgq425
Advocate
Advocate

Dear mdb:

thanks for u reply this message , if u have other idea to solve it , u can tell me . and i will try to solve this in my revit version . thanks

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 5 of 11

scgq425
Advocate
Advocate

Dear mdb:

u can use the code to mirror view changed ,and usr a local data to recored this changed , u alsa can use mvvm or implention the notification influence to get the change .

`_localId` is the private id.

```

RevitCommandData.UiApplication.Idling += new EventHandler<IdlingEventArgs>(UiApplicationOnIdling);

private void UiApplicationOnIdling(object sender ,  IdlingEventArgs args)
{
var uiApp = sender as UIApplication;
var activeViewId = uiApp.ActiveUIDocument.ActiveView.Id;
//var transactionName = string.Concat(args.GetTransactionNames());
if (activeViewId.IntegerValue != _localId.IntegerValue)
{
_localId = activeViewId;
MessageBox.Show($"Changed id : {_localId}");
}

//uiApp.Idling -= new EventHandler<IdlingEventArgs>(UiApplicationOnIdling);
}
 

```

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 6 of 11

scgq425
Advocate
Advocate

i find a fast api to solve this . the idling is a idea , the current way is use` ViewActivating` which in uiapplication , like this code :

```

RevitCommandData.UiApplication.ViewActivating += (sender, args) =>
{
var id = args.CurrentActiveView.Id;
MessageBox.Show($"Changed id : {id}");
};

```

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 7 of 11

scgq425
Advocate
Advocate

Hi mdb :

i find a fast api to solve this . the idling is a idea , the current way is use` ViewActivating` which in uiapplication , like this code :

```

RevitCommandData.UiApplication.ViewActivating += (sender, args) =>
{
var id = args.CurrentActiveView.Id;
MessageBox.Show($"Changed id : {id}");
};

```

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 8 of 11

mdb
Contributor
Contributor

Hi @scgq425,


I am already registered for ViewActivated and DocumentChanged, but they do not notify me when I open a Viewport from a sheet.
I also tried the Idling, but immediately I found (which seems a bit logical to me because it keeps checking constantly) that my Revit became laggy when scrolling in the ProjectBrowser.

 

As a last resort I added a button so i can update the Panel manually.

0 Likes
Message 9 of 11

scgq425
Advocate
Advocate
hi mdb:
in my code , can monitor the view changed , u use the mvvm to create dock
pane or not ?

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes
Message 10 of 11

mdb
Contributor
Contributor

@scgq425 

I suspect you are talking about opening a View itself, I already catch this. 😉

I want a notification when a Viewport is opened in a opened Sheet.

mdb_1-1710922117310.png

 

Or am I wrong and overlooking something?

 

 

 

0 Likes
Message 11 of 11

scgq425
Advocate
Advocate

Hello @mdb  :

in this i understand u put is just view changed , but if u just konw viewport u also can use idling to solve it , if use active the view like a section , the activeViewType is a section type , and u not ,this is a viewsheet type , use this to changed u states.

LanHui Xu 徐兰辉
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog
LinkedIn
Revit/CAD Development | Steel Product Manager

EESignature

0 Likes