Any news for setting global parameters?

Try this code : IN[0] is the name of the global parameter you wish to change and IN[1] is the new value . It should work for all parameter types:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit import DB as db

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

filter =  db.FilteredElementCollector(doc).OfClass(db.GlobalParameter)
gp = [UnwrapElement(p) for p in filter if UnwrapElement(p).Name == IN[0]][0]

#getting the right ParameterValue constructor :
methodname = gp.GetValue().GetType().ToString().rsplit('.',1)[-1]

TransactionManager.Instance.EnsureInTransaction(doc)
try:
	#setting the parameter with the right parametervalue constructor
	gp.SetValue(getattr(db,methodname)(IN[1]))
	out = 'success'
except:
	out = 'failed, check if the parameter value is the right type'

TransactionManager.Instance.TransactionTaskDone()

OUT = out

5 Likes