Last active
August 23, 2021 02:09
-
-
Save chuongmep/31009eb3df277915025be0340a4435f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clr | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
from Autodesk.Revit.DB.Structure import * | |
clr.AddReference('RevitAPIUI') | |
from Autodesk.Revit.UI import * | |
clr.AddReference('System') | |
from System.Collections.Generic import List | |
clr.AddReference('RevitNodes') | |
import Revit | |
clr.ImportExtensions(Revit.GeometryConversion) | |
clr.ImportExtensions(Revit.Elements) | |
clr.AddReference('RevitServices') | |
import RevitServices | |
from RevitServices.Persistence import DocumentManager | |
from RevitServices.Transactions import TransactionManager | |
import System | |
from System.Collections.Generic import * | |
import sys | |
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib') | |
doc = DocumentManager.Instance.CurrentDBDocument | |
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument | |
uiapp = DocumentManager.Instance.CurrentUIApplication | |
app = DocumentManager.Instance.CurrentUIApplication.Application | |
def tolist(obj1): | |
if hasattr(obj1,'__iter__') : return obj1 | |
else : return [obj1] | |
# toList = lambda x : x if hasattr(x, '__iter__') else [x] | |
# element = toList(UnwrapElement(IN[0])) | |
def flatten(x): | |
result = [] | |
for el in x: | |
if hasattr(el, "__iter__") and not isinstance(el, basestring): | |
result.extend(flatten(el)) | |
else: | |
result.append(el) | |
return result | |
#Preparing input from dynamo to revit | |
element = UnwrapElement(tolist(IN[0])) | |
#Do some action in a Transaction | |
TransactionManager.Instance.EnsureInTransaction(doc) | |
#Do Action | |
TransactionManager.Instance.TransactionTaskDone() | |
OUT = element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment