Accessing Revit context menus

Accessing Revit context menus

Kevin.Bell
Advisor Advisor
1,111 Views
7 Replies
Message 1 of 8

Accessing Revit context menus

Kevin.Bell
Advisor
Advisor

Hi,

 

I'm in the process of writing a small plugin which would act as a project browser and do various things which would be helpful to me.

 

The current project browser allows the user to right click on a view to access thinks like 'Duplicate View' or 'Rename' etc.

 

Is there any way I can 'link' to the context menu from addin, so the user right clicks and I get Revit to display the appropriate menu?

 

Or alternatively, is there any way to create a right click menu (I can't see anything in the API documentation).

 

Thanks,

0 Likes
1,112 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk

Afaik, the Revit API does not provide any support for this.

 

However, there is nothing to stop you from using the .NET functionality to access and manipulate the context menus to your heart's content.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 8

Kevin.Bell
Advisor
Advisor

Thanks for the reply Jeremy, but I don't follow what you mean by 'access and manipulate the context menus' as you said there was no support for this?

 

Do you mean - create my own context menus?

 

Thanks.

0 Likes
Message 4 of 8

jeremytammik
Autodesk
Autodesk

Nope, I meant 'use the native Windows API and .NET library functionality to access and manipulate existing context menus'. In Windows, you can do almost anything you like in the user interface, including hook into other applications' context menus, cf.:

 

https://stackoverflow.com/search?q=%22context+menu%22+windows

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 8

Kevin.Bell
Advisor
Advisor

Thanks for your reply, I'll take a look.

 

0 Likes
Message 6 of 8

BobbyC.Jones
Advocate
Advocate

Are you right clicking items on your own dialog?  If so, you can just create your own context menu

 

WPF

https://www.google.com/search?q=wpf+context+menu

 

Windows Forms

https://www.google.com/search?q=windows+forms+context+menu

--
Bobby C. Jones
0 Likes
Message 7 of 8

Kevin.Bell
Advisor
Advisor

I was hoping to link into Revit's menus, and maybe the commands would run from the menu.

 

So for example, when the user right clicks on Sheets node in the Project browser a menu pops up and allow the creation of a new sheet etc - I was hoping to somehow link to the menu so I would not have to create my own and create similar menu options commands....

0 Likes
Message 8 of 8

Kevin.Bell
Advisor
Advisor

I should add, that If I can't access Revit's menu then I'll have to create my own using WPF as you say...

0 Likes