DecoderFallbackException

DecoderFallbackException

Anonymous
Not applicable
547 Views
4 Replies
Message 1 of 5

DecoderFallbackException

Anonymous
Not applicable

Within our company we use unicode symbols in a lot of our family names / family type names. 

Now i'm facing the problem that i can't convert those names to a string. 

 

whenever i want to use:  str( f.Symbol.FamilyName)

on a family that uses a unicode symbol in it's name i get the following exception: 

 

System.Text.DecoderFallback.Exception 

 

Is there a workaround for this? 

0 Likes
548 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Marlo,

 

Can you please put together an absolutely minimal reproducible test case for this, probably including a trivial family definition RFA file, an RVT project making use of it, and an add-in or macro embedded in the RVT to reproduce the problem?

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Then we can pass that on to the development team for further analysis.

 

Thank you!

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hello Jeremy, 

 

Thankyou for your reply. i've attached an empty projectfile with 1 single family using a unicode symbol. 

Also i've attached the used code, meant for ironpython. 

 

 

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Dear Marlo,

 

Thank you.

 

Considering this a bit closer, I am pretty sure that the problem has nothing to do with Revit or the Revit API, but with your usage of Python.

 

I believe you need to set certain switches in Python or explicitly convert between different encoding to handle certain cases of Unicode characters.

 

Which exact line is throwing the exception?

 

Is it this one?

 

  print "family name:     " , f.Symbol.FamilyName

 

If so, it is due to Python expecting you to print ASCII characters only, or something like that.

 

The Python print function is throwing the exception.

 

You need to encode to decode to ASCII or something like that.

 

Here is an old example of calling the Python encode and decode function from 2008:

 

http://thebuildingcoder.typepad.com/blog/2008/10/rvt-file-version.html

 

I struggled with the same thing myself numerous times.

 

That is the most stupid aspect of Python that I know.

 

Best regards,

 

Jeremy



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

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hello Jeremy, 

 

The exception occurs earlier already at: 

families.append( familyManager.CurrentType.Name ) 

 

I've tested this code on many of our projects and it only occurs if the family uses the alt+155 symbol

 

i'll have a look into the link you gave and hopefully i can find a workaround, because i don't have the option of not using these symbols. 

 

 

0 Likes