Invoking Selection.PickPoint() from WPF DockablePane using ExternalEvent doesn't focus ActiveView

Invoking Selection.PickPoint() from WPF DockablePane using ExternalEvent doesn't focus ActiveView

JOfford_13
Advocate Advocate
1,058 Views
11 Replies
Message 1 of 12

Invoking Selection.PickPoint() from WPF DockablePane using ExternalEvent doesn't focus ActiveView

JOfford_13
Advocate
Advocate

Revit 2022

 

Only workaround I've found is to change the UIDocument.ActiveView to a different view and then back but that is SO garbage and slow, plus the UI flashes, plus you have to close the temporary view if it wasn't already open. Please advise if there is a better way.

 

Fun fact, without this the user won't even know that the ExternalEvent has been raised until they actually click back into the ActiveView. They may continue to fire of ExternalEvents from the pane not knowing what is happening. Please fix this bug ASAP.

0 Likes
Accepted solutions (1)
1,059 Views
11 Replies
Replies (11)
Message 2 of 12

jeremy_tammik
Alumni
Alumni

That sounds serious indeed.

  

Can you provide a minimal reproducible case to demonstrate the problem for the development team to analyse?

  

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

  

Thank you!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 12

JOfford_13
Advocate
Advocate

Hello, attached is the most simple demo I can think of. Please advise.

0 Likes
Message 4 of 12

jeremy_tammik
Alumni
Alumni

Thank you. It looks sensible to me. I'll ask the devteam. 

 

Meanwhile, here is possibly a related thread: 

 

https://forums.autodesk.com/t5/revit-api-forum/click-on-dock-pane-deselects-elements/m-p/5279637

 

Revitalizer points out that thread also as a solution to this one:

 

https://forums.autodesk.com/t5/revit-api-forum/dockable-pane-focus/m-p/8887307

 

I hope it helps! I am sure others have encountered this behaviour before, and resolved it, so let's get this solved, please!

  

 

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 12

JOfford_13
Advocate
Advocate

Thanks for the feedback. I've seen these threads before and it seemed neither fix or directly address the ActiveView focus issue. For giggles I tried the SetForegroundWindow approach again in the sample I sent but no luck, much like others in that thread.

0 Likes
Message 6 of 12

jeremy_tammik
Alumni
Alumni

Dear Joe,

 

Thank you for your report, clear description and sample material.

 

Sorry to hear about this.

 

I logged the issue REVIT-182203 [PickPoint in external event from dockable panel does not focus active view] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 7 of 12

jeremy_tammik
Alumni
Alumni
Accepted solution

Dear Joe,

 

Thank you for your patience.

 

Things are looking good.

 

  • The development team confirmed the issue.
  • They opened a new code fix issue to perform the required work, REVIT-182595 [PickPoint in external event from dockable panel does not focus active view].
  • They closed the initial case REVIT-182595 [PickPoint in external event from dockable panel does not focus active view].

Best of all, they suggest a workaround, saying:

 

This issue is caused by the dockable pane being focused when user clicks its buttons, while the PickPoint editor needs the canvas view to be focused instead.

 

We cannot provide a fix for this in previous versions right away.

 

However, in previous versions, users can use the following workaround to activate the canvas view before PickPoint is called:

 

  const int WM_MDIGETACTIVE = 0x0229;
  const int WM_MDIACTIVATE = 0x0222;

  [DllImport("User32.dll", EntryPoint = "SendMessage")]
    public static extern int SendMessage(
      IntPtr hWnd, int Msg, int wParam, int lParam);
  
  private void OnClick( object sender, RoutedEventArgs e )
  {
    TaskDialog.Show( nameof(RevitPane),
      "Raising external event...");
    
    // Activate the current view frame window
    
    var childHwnd = SendMessage( App.UIApp.MainWindowHandle,
      WM_MDIGETACTIVE, 0, 0);
      
    SendMessage( App.UIApp.MainWindowHandle,
      WM_MDIACTIVATE, childHwnd, 0);
    
    RevitPane.Default.ExternalEvent.Raise();
  }

 

I hope this helps.

 

Best regards,

 

Jeremy

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 8 of 12

JOfford_13
Advocate
Advocate

Jeremy, thanks for all the help getting this issue addressed. It's encouraging to see swift action by the development team.

0 Likes
Message 9 of 12

jeremy_tammik
Alumni
Alumni

Thank you for your nice appreciation! I passed it on to the team, and added my own appreciation for their swift and effective action as well.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 10 of 12

jeremy_tammik
Alumni
Alumni

Dear Joe,

 

Thank you again for brining this up and for your patience getting it addressed.

 

The code fix issue REVIT-182595 [PickPoint in external event from dockable panel does not focus active view] has now been resolved and we can expect the improved behaviour to become available in the next major release.

 

Best regards,

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 11 of 12

Sean_Page
Collaborator
Collaborator
This is awesome to hear!
Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 12 of 12

JOfford_13
Advocate
Advocate
Fabulous! Thanks again for taking the time to get this resolved.
0 Likes