Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dynamo python templete

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 :: datafram from one date to another 
Python :: double .get().get() dict python 
Python :: absolut beginners projects in python with tutorial 
Python :: override the text in buttons django admin 
Python :: wonsan 
Python :: set threshold resnet18 pytorch 
Python :: Ascending discending 
Python :: pyqt5 window size 
Python :: python selenium go back to previous page 
Python :: drop a column in pandas 
Python :: python export console output to file 
Python :: import c# dll in python 
Python :: python tkinter change label text 
Python :: python logger format time 
Python :: sdsdsdsdsddsdddsdsdsdsdsdsdsdsdsdsdsdsdsdssdsdsdsdsdsdsdssssssddsdssdssssdsdsdsdsdsdsdsdsdsdsdsdsdsdssdssdsdsdsdsdsdsdsdsdsdsdssd 
Python :: python code for system of odes 
Python :: flask give port number 
Python :: python sort file names with numbers 
Python :: get list of objects in group godot 
Python :: pandas dataframe aggregations 
Python :: f string python not working in linux 
Python :: array comparison in percent 
Python :: remove 0 values from dataframe 
Python :: python yyyymmdd 
Python :: pandas column to numpy array 
Python :: sklearn adjusted r2 
Python :: error 401 unauthorized "Authentication credentials were not provided." 
Python :: Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory. 
Python :: os run shell command python 
Python :: matplotlib title cilpped off 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =