Can not show text of category in revit language-japanese

Hi all!

I using PythonShell get category of selected element, in Revit English show ‘walls’ but Revit Japanese version show [u’\u58c1’].
I tried using Pyrevit and paste ‘#coding: UTF-8’ in the first line of Python script but not solve.
How to fix it.

my script please see link below:

Learn-API/Get elements Category.py at main · Kashima419/Learn-API (github.com)

I think you’ve got the right idea, but I’m not sure you’re on the right track.

However
# -*- coding: utf-8 -*-
Placing this at the top of your file only instructs your computer to read your .py file with utf-8 encoding. This accounts for special symbols (including japanese characters) so that your python interpreter does not throw random errors about weird characters.

However, when your script has been loaded into memory, this encoding tag has serverd its purpose. It has no effect on the code that is actually being run.
Anything in your program’s memory is not affected by this.

Revit (in memory) responds to your script (in memory).
Since your revit is setup in Japanese, you will most likely get a UTF encoded string from revit. But your python script doens’t automatically convert these utf codes into actual utf.

Try doing this:
name = i.Category.Name.encode('utf-8')
print(name)

I’m not exactly sure if utf-8 is going to work, you might need utf-16.

3 Likes

Thank you! This link below solved!!!

Can not Get category in Revit Language Japanese by type data ‘List’ - Developers - Dynamo (dynamobim.com)

1 Like