What kind of value does the setglobalparameter need


#1

Hi,
I’ve been tinkering with clockwork and the setglobalparameter function but when I put a number, integer or a string in the value input it doesn’t work.
Does anyone have a solution?


#2
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§ for p in filter if UnwrapElement§.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


#3

use this code in python script

once made by Mostafa

and check in revit the storage type off the global parameter