Revit API

Reply
Contributor
Frigotherm
Posts: 11
Registered: ‎03-16-2012
Message 1 of 7 (389 Views)
Accepted Solution

Active window name

389 Views, 6 Replies
10-15-2012 02:03 AM

Hi everybody!

 

whats the best way (in c#) to get the active window name? (for example the name of the drawing window, the name of the main app window, etc...)

 

if possible without using the windows api..

 

thank you

 

best regards

 

Frigo

 

Hi Frigo,

 

Are your talking about Revit? And want to get the Revit's active view's name and Revit main frame name?

 

The simplest way to get the active Revit view name is: 

 

View class name + ": " + view name + " - " + ProjectName.

 

 

For example: Floor Plan: 2 - Mech - Project1

 

Floor Plan is the view class name.

Project1 is the project name.

 

The active view name can be easily get by : doc.ActiveView.Name property.

 

 

With regard to get the Revit's main app name, there is no straightforward Revit APi can be used. You need to resort to the windows API, I think.

 

 

Hi all, what about this:

 

System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle

I haven't tested this, but maybe it may help you.

 

 

Cheers,

Revitalizer

ADN Support Specialist
Joe.Ye
Posts: 328
Registered: ‎03-05-2010
Message 2 of 7 (367 Views)

Re: Active window name

10-23-2012 03:47 AM in reply to: Frigotherm

 

Hi Frigo,

 

Are your talking about Revit? And want to get the Revit's active view's name and Revit main frame name?

 

The simplest way to get the active Revit view name is: 

 

View class name + ": " + view name + " - " + ProjectName.

 

 

For example: Floor Plan: 2 - Mech - Project1

 

Floor Plan is the view class name.

Project1 is the project name.

 

The active view name can be easily get by : doc.ActiveView.Name property.

 

 

With regard to get the Revit's main app name, there is no straightforward Revit APi can be used. You need to resort to the windows API, I think.

 

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 3 of 7 (355 Views)

Re: Active window name

10-24-2012 12:28 AM in reply to: Joe.Ye

Hi all,

 

if talking about the main window, the title displayed consists also of product type and year, which can be got by Application.VersionName and Application.VersionNumber.

Window title may change to a shorter string if window is resized.

Also, in a zero-document state, title looks like "[Recent files]", but this depends on Revit's current language.

 

 

Cheers,

Revitalizer

ADN Support Specialist
Joe.Ye
Posts: 328
Registered: ‎03-05-2010
Message 4 of 7 (339 Views)

Re: Active window name

10-29-2012 09:13 AM in reply to: Revitalizer

 

Hi Revitalizer,

 

Good idea to compose the caption string. Normally this should work fine to get the correct string.

 

However there are situations the caption is different. For example, the Revit used by the ADN partners, there is a sub-string  "Not for resale version" in the caption string, the other parts are the same. There maybe some other situations, for example , the Revit education version.

 

Cheers,

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 5 of 7 (333 Views)

Re: Active window name

10-30-2012 12:58 AM in reply to: Frigotherm

Hi joe.ye,

 

yes, I know that there are special strings for special versions.

Also, these strings are localized (as the "[Recent files]" string is).

 

After all, I think there is no possibility to get the main window title string except using Windows API functions.

I do not see why not to do so, by the way.

 

 

 

Best regards,

Revitalizer

Valued Contributor
Revitalizer
Posts: 88
Registered: ‎09-07-2012
Message 6 of 7 (329 Views)

Re: Active window name

10-30-2012 02:35 AM in reply to: Revitalizer

Hi all, what about this:

 

System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle

I haven't tested this, but maybe it may help you.

 

 

Cheers,

Revitalizer

ADN Support Specialist
Joe.Ye
Posts: 328
Registered: ‎03-05-2010
Message 7 of 7 (314 Views)

Re: Active window name

11-01-2012 03:21 AM in reply to: Revitalizer

 

Cool, I confirmed the result is correct. 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.