Hi guys,
Until now all topics talking about global parameters is talking about how to read the values of global parameters,
any news on how we can set these values and change them?
Hi guys,
Until now all topics talking about global parameters is talking about how to read the values of global parameters,
any news on how we can set these values and change them?
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
Hi @Mostafa_El_Ayoubi thank you for replying and this is what am searching for
Looks like something is in the works on OOTB Dynamo as well: