Revit's UI language and identifiying transaction in DocumentChanged event

Revit's UI language and identifiying transaction in DocumentChanged event

kinjal
Enthusiast Enthusiast
1,294 Views
6 Replies
Message 1 of 7

Revit's UI language and identifiying transaction in DocumentChanged event

kinjal
Enthusiast
Enthusiast

Dear all,

 

We need to "listen" to certain document-level activities, like "Paste", "Component" (place family instance), "Load Family" and so on. We do that in DocumentChanged event handler. 

 

As far as we know, the only way to identify what-operation-just-took-place is to check for transaction-names returned by GetTransactionNames() of DocumentChangedEventArgs in DocumentChanged event. There doesn't seem to be an enum or kind.

 

One of the biggest issues with going by textual transaction names is that, it changes with on Revit's ui language (Russian, Chinese, etc).

We certainly want to cater to non-English Revit installations as well.

 

Did anyone encounter this earlier? What is best way to handler this?

 

Any solution or reference to right direction would be a great help.

 

Thanks in advance!

 

Best regards,

Kinjal.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


0 Likes
1,295 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear Kinjal,

 

Thank you for your query.

 

The question on determining the language of Revit user interface has already been answered here in this forum:

 

https://forums.autodesk.com/t5/revit-api-forum/how-to-get-the-language-of-revit-user-interface/td-p/...

 

Just search the Revit API doc for 'language':

 

http://www.revitapidocs.com/2017/1acafee6-95e0-50dd-2e46-8951e9405311.htm

 

 

  // application is UIControlledApplication

  LanguageType lang = application.ControlledApplication.Language;

 

Please always search this forum and the Internet in general for an answer before posting new questions.

 

Regarding the transaction names, it would be a great pity if there is no language independent way to obtain that information.

 

I am checking that with the development team for you.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 3 of 7

kinjal
Enthusiast
Enthusiast

Hi Jeremy,

 

Thanks for the reply.

 

Determining Revit's ui lang wasn't my issue.. Rather, as you mentioned, it is about finding a language independent way to obtain transaction-identification-information.

 

Looking forward to your reply about development team's response.

 

Best regards,

Kinjal.

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

Dear Kinjal,

 

The development team reply:

 

The names are likely language-specific. Note that transactions themselves do not really have an independent identity in Revit, they may be invoked by Revit tools, add-ins and may even be a part of a TransactionGroup or sequence of independent transactions.

 

To watch for invocation of specific Revit tools, you can use AddInCommandBinding and the BeforeExecuted event to see that the tool is invoking. That, coupled with the DocumentChanged subscription, might better be able to identify which DocumentChanged event callbacks you should pay attention to.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes
Message 5 of 7

RPTHOMAS108
Mentor
Mentor

If you only need to recognise certain transactions triggered by certain things and if there are many of you then perhaps you can test with the language switch in the command line to determine the transaction names of interest to you.

 

Language command line switch

 

There are 13 (unlucky for some) languages to choose from.

 

Would be good if there was an API function .GetUITransactionName(Command_ID), presumably these strings exist somewhere as a localised resource since you don't get random verbs in the undo stack when you activate commands.

0 Likes
Message 6 of 7

kinjal
Enthusiast
Enthusiast

Thanks @jeremytammikJeremy for passing on insights from dev team. We are trying to get better grip on what-changed-in-the-project. We wouldn't have much insight on what is going on for transactions committed by addins, however we hope to better identify and process Revit's transactions are they are pretty much standard.

 

Thanks @RPTHOMAS108 for the link. We used the command line to verify if transaction names differ per lang. I totally agree with your  point about "GetUITransactionName()". It would had been very hand, in fact that is what we hoped is available somewhere.

 

 

Kinjal Desai
Fullstack developer @ Dwaravati
Delivering high quality programmatic boosts for your already beautiful Revit


0 Likes
Message 7 of 7

jeremytammik
Autodesk
Autodesk

Please submit a wish for it in the Revit Idea station and ensure it gets lots of votes.

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes