1

I'd like to print dialogs in french using pyRevit scripts. As soon as I include an accent like "ê" in my code, the pyRevit script doesn't even execute.

But if I do for instance print "être" in RevitPythonShell, no problem.

Why? Why the different treatment, and can it be handeled with pyRevit?

Thanks a lot, Arnaud.

Arnaud
  • 445
  • 4
  • 18

2 Answers2

3

It is all about encoding and decoding. I reccommend you to read this nice article on the subject : http://sametmax.com/lencoding-en-python-une-bonne-fois-pour-toute/ You should prefix all your scripts with : # coding: utf8

# coding: utf8

__title__ = "TextEncoding"

print("être")

PyRevit output : enter image description here

Cyril Waechter
  • 517
  • 4
  • 16
  • Thank you both! It now works fine. That last comment by Daren is actually what I was also missing! Didn't pay attention to that.. Thanks again! – Arnaud Dec 04 '17 at 08:26
2

Im not sure about PyRevit, but I can use French characters when making Revit Dialogs in the RevitPythonShell like this:

dialog = TaskDialog("être")
dialog.MainContent = "être"
dialog.Show()

And when using Winforms like this:

import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form, Label

form = Form()
form.Width = 300
form.Height = 100

label = Label()
label.Text = 'Here is some French Text: "être"'
label.Width = 280
label.Height = 70
label.Parent = form

form.ShowDialog()

Could you post some code showing in what instance it fails?

Callum
  • 578
  • 3
  • 8
  • Thank you Callum! It was related to the encoding of my text editor.. rookie mistake, sorry :s And as for within RPS, it works fine without any additional command! Thanks! – Arnaud Dec 04 '17 at 08:27