Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dynamo scripts template

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.7Lib')

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]
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
Comment

PREVIOUS NEXT
Code Example
Python :: Finding the sum of even Fibonacci numbers less than or equal to given limit 
Python :: ellipsis in python as index 
Python :: how to get more than one word in a list in python 
Python :: convert streamlit imageBytes = file.read() to image 
Python :: first openfaas python function 
Python :: dropdown menu for qheaderview python 
Python :: Filler values must be provided when X has more than 2 training features 
Python :: matplotlib set y lim 
Python :: how to lock writing to a variable thread python 
Python :: pandas series select first value 
Python :: how to add stylesheet in django 
Python :: wait for page to load selenium python 
Python :: pypi toml 
Python :: 2 d array in python with zeroes 
Python :: render_template not showing images 
Python :: array must not contain infs or NaNs 
Python :: vertical line in matplotlib 
Python :: python counter get most common 
Python :: .annotate unique distinct 
Python :: python get date next week 
Python :: how to use python to open camera app using python 
Python :: How to create an efficient median finder for a stream of values, in Python? 
Python :: os.remove directory 
Python :: save ml model using joblib 
Python :: python print dictionary line by line 
Python :: fill pixels with zeros python opencv 
Python :: dataframe unique values in each column 
Python :: delay time python 
Python :: how to end the python program 
Python :: pandas dataframe rename column 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =