Created
September 17, 2022 23:08
-
-
Save johnpierson/646003d74fa7eabc5d89256e46bc225e to your computer and use it in GitHub Desktop.
This is your first python node in Dynamo.
This file contains hidden or 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 the common language runtime to communicate with the Revit API | |
import clr | |
# import the revit api | |
clr.AddReference('RevitAPI') | |
from Autodesk.Revit.DB import * | |
# import dynamo's revit nodes | |
clr.AddReference('RevitNodes') | |
import Revit | |
clr.ImportExtensions(Revit.GeometryConversion) | |
clr.ImportExtensions(Revit.Elements) | |
# import Revit's transaction manager | |
clr.AddReference('RevitServices') | |
import RevitServices | |
from RevitServices.Persistence import DocumentManager | |
from RevitServices.Transactions import TransactionManager | |
# reference the active document | |
doc = DocumentManager.Instance.CurrentDBDocument | |
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument | |
#Preparing input from dynamo to revit | |
element = UnwrapElement(IN[0]) | |
boolean = IN[1] | |
#Do some action in a Transaction | |
TransactionManager.Instance.EnsureInTransaction(doc) | |
# pin the element using this https://apidocs.co/apps/revit/2023/c37bc7f9-409e-9b8a-f491-f700228985e2.htm | |
element.Pinned = boolean | |
TransactionManager.Instance.TransactionTaskDone() | |
OUT = element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment