There is a "Preview" button in the type properties dialog. If you click it, then, as far as I know, a copy of the current document will be created with a new view (I could be wrong here):
The problem is that in this case IUpdater is triggered, which can lead to negative consequences.
Question - how can I detect that this Preview is open or how can I detect that the dialog for editing type properties is open?
Solved! Go to Solution.
Solved by ModPlus. Go to Solution.
You use the native Windows API to detect that a specific Windows form is open. Presumably, this can also be done in .NET. You can search for something like ".net detect form open" to learn more:
You can try to track the DocumentChanged event, Revit creates elements and a view with a persistent name ‘Modify type attributes’. This name is probably language dependent, but Revit does not create any other events
@nice3point wrote:This name is probably language dependent
Unfortunately, names are language-dependent
@jeremy_tammik did as you suggested. A small auxiliary class:
using System;
using System.Runtime.InteropServices;
using Autodesk.Revit.UI;
/// <summary>
/// Initializes a new instance of the <see cref="RevitWindowUtils"/> class.
/// </summary>
/// <param name="uiApplication"><see cref="UIApplication"/></param>
public class RevitWindowUtils(UIApplication uiApplication)
{
private readonly IntPtr _mainWindowHandle = uiApplication.MainWindowHandle;
[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
/// <summary>
/// Is main Revit window active
/// </summary>
public bool IsMainWindowActive() => GetActiveWindow() == _mainWindowHandle;
}
I create and store its static instance in the application class, and check it in IUpdater as follows:
public void Execute(UpdaterData data)
{
if (!App.RevitWindowUtils.IsMainWindowActive())
return;
Great! Glad to hear that it helped. Thank you for sharing your implementation. It looks nice and generic, and may be useful for other situations as well.
... so, I shared it on the blog for future reference:
https://thebuildingcoder.typepad.com/blog/2024/05/lengthen-ducts-and-highlight-links.html#4
Thank you again for this.
Can't find what you're looking for? Ask the community or share your knowledge.