REVIT.API language property

Hello 2 all,

it is an easy question, but i still don’t know enough to answere it on my own.
I just want to check the lanuage of the RUNNING REVIT instance.
Regarding on the result i want to make an different output from my python code.

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

This is my code til now :slight_smile:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN

import REVITServices

languageENU=IN[0]
languageDEU=IN[1]

##  CODE to check the language from REVIT ###
Revitlanguage 

   if  Revitlanguage == ENU
      result = languageENU
      else 
      result= languageDEU

OUT=result

Thank you for help :slight_smile:

You need some extra imports to access the LanguageType enumeration. Here’s a working version of what you’re trying to achieve:

import clr

# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

languageENU=IN[0]
languageDEU=IN[1]

##  CODE to check the language from REVIT ###
Revitlanguage = app.Language

if Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.English_USA:
	result = languageENU
else:
    result= languageDEU

OUT=result
6 Likes

Is this exposed somewhere?

Hi Yna,
What exactly do you mean by exposed? You need access to the Revit API to get those enumerations, if that’s what you mean.

Yes, I was guessing this from your code, I just wanted to know if there was any additional documentation we could refer to…

@T_Pover

Thank you so much :slight_smile: !!!

I just thought – learning dynamo and python would be enough at the beginner level :-p but up on now --> REVIT API is doing some decent overflow to me - haha

1 Like

I just start typing and when Dynamo starts whining about missing modules I start copying text from existing nodes :slight_smile:

1 Like

OK, typical answer and good advise. Wouldn’t it be useful to sum-up something about it in the Share category? Let’s say someone would wish to start a new post with few information…

Einar made a great post about this a while back: https://forum.dynamobim.com/t/dividing-parts-with-dynamo/5388/5

1 Like

Great, I think it would be a good idea to put it in the Share category with an specific title, I have noticed that a lot of information cannot be found easily because of an inappropriate referencing…

Dynamos GitHub Wiki page is the place to go when you are looking for the different imports in python nodes: (again with a bit odd title “Python-0.6.3-to-0.7.x-Migration”)

1 Like
import clr

# Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

languageENU=IN[0]
languageDEU=IN[1]
languageESP=IN[2]
languageFRA=IN[3]
languageITA=IN[4]
languageCHS=IN[5]
languageCHT=IN[6]
languageJPN=IN[7]
languageKOR=IN[8]
languageRUS=IN[9]
languageCSY=IN[10]
languagePLK=IN[11]
languagePTB=IN[12]


##  CODE to check the language from REVIT ###
Revitlanguage = app.Language
	if Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.English_USA:
		result = languageENU
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.German:
		result = languageDEU
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Spanish:
		result = languageESP
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.French:
		result = languageFRA
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Italian:
		result = languageITA
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified:
		result = languageCHS
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Traditional:
		result = languageCHT
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Japanese:
		result = languageJPN
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Korean:
		result = languageKOR
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Russian:
		result = languageRUS
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Czech:
		result = languageCSY
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Polish:
		result = languagePLK
	elif Revitlanguage == Autodesk.Revit.ApplicationServices.LanguageType.Brazilian_Portuguese:
		result = languagePTB
	else 
		result = languageDEU


OUT=result

What is wrong with the code? And it seems I have to use every input port (optional would be better). And is there a difference in the parameter names between English USA and English GB ?

String.ByRevitLanguageType.dyf (11.7 KB)