Error in Python script in Revit 2018 and 2019 but in Revit 2020 works

Hello everyone and thank you very much for your time.

I comment on my mistake, I am developing a script to obtain the names, types, and units of the project parameters, I had made the python script in Revit 2020 and everything worked very well, the problem is when I try to run it in versions of Revit 2019 or earlier. The safest thing is that it is due to the API, so I ask for your help to know if something I have to change for these versions or how I can solve the problem. The message tells me the following: Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 12, in
UnicodeDecodeError: (‘unknown’, u ‘\ xfc’, 0, 1, ‘’)

This is the Code for the Python Script

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

param = UnwrapElement(IN[0])
name,groups, types, units = [],[],[],[]

    for i in param:
    	dfn = i.GetDefinition()
    	name.append(str(dfn.Name))
    	groups.append(str(dfn.ParameterType))
    	types.append(str(dfn.ParameterGroup))
    	units.append(str(dfn.UnitType))	

    OUT = name,groups, types, units

@Luiscko It seems like your parameter name(s) have Latin Character(s) [like ü] in it and IronPython doesn’t like it as described here

Try this instead

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

param = UnwrapElement(IN[0])
name,groups,types,units = [],[],[],[]

for i in param:
	dfn = i.GetDefinition()
	name.append(unicode(dfn.Name))
	groups.append(unicode(str(dfn.ParameterType)))
	types.append(unicode(str(dfn.ParameterGroup)))
	units.append(unicode(str(dfn.UnitType)))
	
OUT = name,groups,types,units
3 Likes

Thank you very Much @AmolShah I am new in coding and this is pretty helpful for now and for the future coding with the special Latin character(s) thanks again

1 Like