Last active
May 3, 2017 22:17
-
-
Save dobriai/be39bd4e31111e3f0b41b3ddfa65ec20 to your computer and use it in GitHub Desktop.
Dynamo Revit Python Snippets
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
# Universal header | |
import clr | |
clr.AddReference('ProtoGeometry') | |
from Autodesk.DesignScript.Geometry import * | |
clr.AddReference("RevitNodes") | |
import Revit | |
from Revit.Elements import * | |
clr.AddReference('RevitAPI') | |
import Autodesk | |
from Autodesk.Revit.DB import * | |
# Import DocumentManager | |
clr.AddReference("RevitServices") | |
import RevitServices | |
from RevitServices.Persistence import DocumentManager | |
from RevitServices.Transactions import TransactionManager | |
doc = DocumentManager.Instance.CurrentDBDocument | |
# uiapp = DocumentManager.Instance.CurrentUIApplication | |
# app = uiapp.Application | |
# ============================================================ | |
# Get all Walls and put out the WallType for each one | |
collector = FilteredElementCollector(doc) | |
elems = collector.WherePasses(ElementClassFilter(Wall)).ToElements() | |
OUT = [] | |
for elem in elems: | |
wt = elem.WallType | |
OUT.append(wt) | |
# ============================================================ | |
# Get Walls from IN[0] and set all their types to the WallType IN[1] | |
TransactionManager.Instance.EnsureInTransaction(doc) | |
OUT = [] | |
for elem in IN[0]: | |
# wt = elem.InternalElement.WallType | |
# OUT.append(wt) | |
elem.InternalElement.WallType = IN[1].InternalElement | |
OUT.append(elem) # For debugging or chaining | |
TransactionManager.Instance.TransactionTaskDone() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment