How to manipulate the "Project Browser" when programmatically activating a view?

How to manipulate the "Project Browser" when programmatically activating a view?

Anonymous
Not applicable
2,108 Views
11 Replies
Message 1 of 12

How to manipulate the "Project Browser" when programmatically activating a view?

Anonymous
Not applicable

I want to make the currently activated view be the top of the "project browser."  I can activate the view no problem with the API's.  However, i can't figure out how to ensure that this newly activated view is the topmost item in the Project Browser.  Any ideas?

0 Likes
2,109 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
There is no API access to the OOTB Project Browser unfortunately so what youa re wanting to do is impossible 😞

Regards

Phillip Miller
0 Likes
Message 3 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Do you mean that you want to make sure that you are on the "Views" node in the Project Browser?

Please clarify more.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 4 of 12

Anonymous
Not applicable

To clarify, I'll give a simpler example.  I want to make a form that displays the list of all Views in the file.  When a user clicks one, it will activate that view as the activeview.  I can do that.

 

But also, I want to make sure the Project Browser has that view at the top of the browser.  Like "Center Graph" in Catia.  Right now, I can activate that view, but the view is buried in the project browser.  It should be at the top.

0 Likes
Message 5 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

What do you mean with " Like "Center Graph" in Catia" can you explain more or provide link or images please.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 6 of 12

Anonymous
Not applicable

 

d

20161024_1.jpg

s

20161024_2.jpg

s

 

20161024_3.jpg

sa

20161024_4.jpg

sd

 

0 Likes
Message 7 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Now I see. You can do it through the WinAPI. You have to find the Treeview item with the same name as your schedule and use the SetFocuse or EnsureVisible (I'm not sure of the name) method.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 8 of 12

Anonymous
Not applicable

Thanks for the info.  I've been reading up on accessing the winAPI with c#, and there ain't a lot of material on how to get started.  How do I know what libraries and references to load?  Do you have any sample code that could get me started on setting up the winAPI references in c#?  Once I know where to begin, I can handle the rest more easily.  

0 Likes
Message 9 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

Ok you can start with: PInvoke.net

 

There is all what you need to use WinAPI, try to use functions like FindWindow and SendMessage, etc.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 10 of 12

Anonymous
Not applicable

Mustafa,

Thanks so much for that link.  It truly is a goldmine.  I am already able to access the Revit UI and get some rudimentary info from it.  

 

However, I'm unable to make the jump from the top-level menu items, to the submenu items like the Project Browser.  Maybe I'm doing something wrong, but whenever i use GetSubMenu, it always returns a zero result.  I use the GetMenu and the GetWindow which will give me the Revit UI.  However, when I use submenu commands, it is always zero.  Here is a simplified version:

 

     IntPtr RevitAppNumber = RevitWndHandle(uiApp.ActiveUIDocument.Document.Title.ToString());
     IntPtr GGG = GetMenu(RevitAppNumber);
     IntPtr LLL0 = GetSubMenu(GGG, 0);

 

 

RevitWndHandle is a subroutine that I wrote up to get the handle.  

 

No matter what number I put in for the GetSubMenu, it's always a null.

 

But, the MenuItemCount is more than 1.

 

     IntPtr mainMenu = GetMenu(RevitAppNumber);
     IntPtr fileMenu = GetSubMenu(mainMenu, 0);
     uint itemIndex = (uint) GetMenuItemCount(fileMenu);

 

This returns a MASSIVE itemIndex like 1515123412342.  Which is also weird.  I'm new to this WinAPI stuff, so any advice you could give would help immensely.  

 

 

.

.

.

.

0 Likes
Message 11 of 12

Mustafa.Salaheldin
Collaborator
Collaborator

OK. Can you please share your VS project so that I may have a look and know where is the problem.

In some cases if the WinAPI can't do the job you may need to use a mix of UIAutomation and WinAPI.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 12 of 12

Anonymous
Not applicable

I guess before I start putting a bunch of code up here, perhaps a better question would be to assertain what GetMenu and GetSubMenu do.  I was under the impression that GetMenu got menus in the UI.  However, it appears that it might just be the topmost menu items in the UI.  And the SubMenu is the pulldown that all windows applications have under their menu items.  

 

So, maybe there is a sub-command in GetWindow that finds the sub-windows that would contain the TreeView in the Project Browser.  Or maybe someone knows how to find sub-browsers or docked windows in the Revit UI using the user32.dll.  

 

 

0 Likes