Script bombs out with unhandled exception (Orchid Parameter.Setvalue)

Hello, I’d really appreciate a hand here. This script is designed to read a family parameter, convert it to upper case, and stuff it back in. I had it working for a while but not reliably, and now it generates an unhandled exception error. I logged the issue to Github but the exception error is likely related to some improper use of Orchid Parameter.Setvalue. I’ve experimented with lacing but so far no luck.
ME Family Parameter To Upper Case.dyn (48.8 KB)

(I have a couple of nodes in there where I am experimenting with flattening the data before it hits the .setvalue routine, presently not connected)

Hi @MuirEng

I’m not sure what might be the cause of that but here is another workaround using python to set parameter names to Upper case:

import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

families = tolist(UnwrapElement(IN[0]))


class FamilyLoadOption(IFamilyLoadOptions):
	def OnFamilyFound(self,familyInUse,overwriteParameterValues):
		overwriteParameterValues = True
		return True
	
	def OnSharedFamilyFound(self,sharedFamily,familyInUse,FamilySource,overwriteParameterValues):
		return True

reload = []
failed = []
newnames = []
for family in families:
	TransactionManager.Instance.ForceCloseTransaction()
	famdoc = doc.EditFamily(family)
	FamilyMan = famdoc.FamilyManager
	TransactionManager.Instance.EnsureInTransaction(famdoc)
	check = 0
	for param in FamilyMan.Parameters:
		paramName = param.Definition.Name
		newname = paramName.upper()
		if paramName in paramName:
			
			try:
				FamilyMan.RenameParameter(param,newname)
				check += 1
				newnames.append(newname)
			except:
				failed.append(paramName)
		else:
			continue
		
	if check > 0:
		reload.append(famdoc.LoadFamily(doc,FamilyLoadOption()))
	TransactionManager.Instance.TransactionTaskDone()
	TransactionManager.Instance.ForceCloseTransaction()
	famdoc.Close(False)
	
	
OUT = newnames, reload, failed
1 Like

Thank you Kulkul,

As far as i can tell your routine is designed to change family parameter names to upper case. This could be useful but not what I am trying to do. My script is designed to rename family parameter VALUES to upper case, for all family types. (set value for type parameters, default value for instance parameters). Sorry if I was not clear about this.

If you can give me some advice how to modify your python to do this instead I will be most grateful.
thank you!