Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

doc.EnableWorksharing() & Language versions

7 REPLIES 7
Reply
Message 1 of 8
Julian.Wandzilak
323 Views, 7 Replies

doc.EnableWorksharing() & Language versions

I am trying to automate a process of file creation. One of the step is to enable worksharing and to do it I am using:

 

 

doc.EnableWorksharing("Shared Levels and Grids", "Workset1");

 

 

By doing it, I am getting two default worksets with their default names. But in the other language versions, those worksets are named differently. As much as I am fine with using only English version, it would be good to know if someone has a solution to it. Because, for sure, Revit knows how to use different names in different languages.

 

Of course I could potentially use:

 

ControlledApplication.Language;

 

 to get a language and then make my own dictionary. It is doable but it is a big workaround (13 languages).

 
blog: w7k.pl more about me: Linkedin Profile
My add-ins for Revit: Drafter(180+ scripts) & Leveler
7 REPLIES 7
Message 2 of 8

Thank you for your good question. I asked the development team for you.

  

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

Indeed, a very good point. After some discussion and clarification with the development team, they created a new development ticket for your requirement, REVIT-204796 [Exposes enableWorkSharingIfNecessary() as public API]. 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. New record turn-around time!

  

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

Thanks! I will be happy to see it available as public API 😉 

blog: w7k.pl more about me: Linkedin Profile
My add-ins for Revit: Drafter(180+ scripts) & Leveler
Message 5 of 8

So it is my time to come back with follow up. Having some time, I decided to implement a default language checker which comes back with names for both of worksets. It was rather tedious job, so please find it below. I haven't double-checked all of them, so please report if something is wrong :

 

 

string defaultLevelsAndGrids = "";
string defaultWorkset1 = "";

switch (app.Language.ToString())
{
    case "Unknown":
        defaultLevelsAndGrids = "Shared Levels and Grids";
        defaultWorkset1 = "Workset1";
        break;
    case "English_USA":
        defaultLevelsAndGrids = "Shared Levels and Grids";
        defaultWorkset1 = "Workset1";
        break;
    case "German":
        defaultLevelsAndGrids = "Gemeinsam genutzte Ebenen und Raster";
        defaultWorkset1 = "Bearbeitungsbereich1";
        break;
    case "Spanish":
        defaultLevelsAndGrids = "Niveles y rejillas compartidos";
        defaultWorkset1 = "Subproyecto1";
        break;
    case "French":
        defaultLevelsAndGrids = "Quadrillages et niveaux partagés";
        defaultWorkset1 = "Sous-projet 1";
        break;
    case "Italian":
        defaultLevelsAndGrids = "Griglie e livelli condivisi";
        defaultWorkset1 = "Workset1";
        break;
    //case "Dutch":
    //defaultLevelsAndGrids = "Shared Levels and Grids";
    //defaultWorkset1 = "Workset1";
    //break;
    case "Chinese_Simplified":
        defaultLevelsAndGrids = "共享标高和轴网";
        defaultWorkset1 = "工作集1";
        break;
    case "Chinese_Traditional":
        defaultLevelsAndGrids = "共用的樓層和網格";
        defaultWorkset1 = "工作集 1";
        break;
    case "Japanese":
        defaultLevelsAndGrids = "共有レベルと通芯";
        defaultWorkset1 = "ワークセット1";
        break;
    case "Korean":
        defaultLevelsAndGrids = "공유 레벨 및 그리드";
        defaultWorkset1 = "작업세트1";
        break;
    case "Russian":
        defaultLevelsAndGrids = "Общие уровни и сетки";
        defaultWorkset1 = "Рабочий набор 1";
        break;
    case "Czech":
        defaultLevelsAndGrids = "Sdílená podlaží a osnovy";
        defaultWorkset1 = "Pracovní sada1";
        break;
    case "Polish":
        defaultLevelsAndGrids = "Współdzielone poziomy i osie";
        defaultWorkset1 = "Zadanie1";
        break;
    //case "Hungarian":
    //defaultLevelsAndGrids = "Shared Levels and Grids";
    //defaultWorkset1 = "Workset1";
    //break;
    case "Brazilian_Portuguese":
        defaultLevelsAndGrids = "Níveis e eixos compartilhados";
        defaultWorkset1 = "Workset1";
        break;
    case "English_GB":
        defaultLevelsAndGrids = "Shared Levels and Grids";
        defaultWorkset1 = "Workset1";
        break;
    default:
        defaultLevelsAndGrids = "Shared Levels and Grids";
        defaultWorkset1 = "Workset1";
        break;
}

 

 

There is an "Unknown type" - I didn't know if I should add it (default in a switch would cover it). In the end, I left it in the code. What should we do to get this type from revit api? 

 

There are some interesting findings in it. Firstly, we have two langagueType (hungarian and dutch) in Revit API. I couldn't find them in language help.
https://help.autodesk.com/view/RVT/2023/ENU/?guid=GUID-BD09C1B4-5520-475D-BE7E-773642EEBD6C

I assumed that those language versions are being developed, so for now I commented them out in the code.

 

Also, it is interesting that some translators decided to keep Workset1 as default - We have it not only in English but also in Italian and Brazilian Portuguese. I like this approach because in my opinion, Polish translation "Zadanie1" is rather bad and confusing (it means something closer to "task"). Because of that I saw some projects where worksets were named "Tasks of Adam", "Tasks of Kate" etc.

 

The other interesting thing is lack of consistency regarding number "1". In most languages we don't have extra space between Workset and 1, but in Russian, French and traditional Chinese with have. Chinese is double interesting because in simplified Chinese we don't have empty space.

blog: w7k.pl more about me: Linkedin Profile
My add-ins for Revit: Drafter(180+ scripts) & Leveler
Message 6 of 8

Dear Julian,

  

Thank you for taking on this laborious task and sharing the results. I passed it on to the development team for review together with the very valid questions you raise. To do so, I also added it to The Building Coder samples, so I can share a handy link to it:

  

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/Util.cs#L2144-L...

  

I wish you a happy weekend.

  

Jeremy

  

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

They took a look and reply succinctly: The approach GetDefaultWorksetNames is using -- lookup table based on language -- should work well to get the names in local language.

    

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

I tested it in a free tool I am building (Workset creator from a JSON file) and it works nicely - Ideally some people will test it in different languages 😉

 

It made me wonder about how Revit is treating languages - I knew before that if for example you load a family (with family types in text file) from different language libraries you will get an error (because of a translation of default parameters like height/width/ length). But you can open a project in a correct language, then load families into project and after opening again in your previous language you will be fine most of the time.

Is it possible to get parameter name in a currently used language? That would be super useful for translations etc.  

 

Also, I started to look around and decided to test the levels - I was slightly disappointed to learn that "Level.Create(doc, elevation)" adds a level with a name similar to the last created or last renamed (whatever happened last).

It works this way even if you decide to delete all the levels in a project - It is not easy but I managed to delete them manually. After doing it you might get into a problem of creating new levels. And here it starts to be interesting. If you add a level using Revit API, revit still keeps the same way of naming the levels -->for example you will get Level 3 (after deleting Level 1 and 2).But if you go to View/plan views/ you will get a pop-out which gives you a default Level 0 / Poziom 0 (I tested it also in Polish)  

That would mean that Revit saves somewhere the name of the next level to create, and at the same time somewhere keeps the default level values. Enough nerding for today. 

blog: w7k.pl more about me: Linkedin Profile
My add-ins for Revit: Drafter(180+ scripts) & Leveler

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community