Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set Parameter Dynamo Sample
#Copyright(c) 2020, chuongho
# @chuongmep, https://chuongmep.com/
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
from System.Collections.Generic import *
import clr
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
uiapp = DocumentManager.Instance.CurrentUIApplication
elements = IN[0]
parameters = IN[1]
values = IN[2]
output = []
if not isinstance(elements, list):
elements = [elements]
if not isinstance(parameters, list):
parameters = [parameters]
if not isinstance(values, list):
values = [values]
TransactionManager.Instance.ForceCloseTransaction()
t = Transaction(doc, 'SetParameterValue')
t.Start()
for e in elements:
for p, v in zip(parameters, values):
e.SetParameterByName(p, v)
output.append(e)
t.Commit()
#Assign your output to the OUT variable
OUT = output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment