Hi Everyone,
This script maybe reaching a bit here, but its something that could be useful though not really sure if it is possible.
I am essentially trying to automate the Trim Extend to Corner function on the Modify tab in Revit using a python script through Dynamo.
So far I have written this code in two parts. The first was to select elements in the Revit space using Element IDs the second was to basically select the Trim Extend to Corner function. Both of these scripts were successful but putting the two together has not been successful. Although there are no errors, the script does not work.
Below you will find the .dyn file, a snap of the dynamo graph, python node code and a snap of the two duct pieces I am trying to join.
The idea behind this is to naturally run this script on a number of elements that require the Trim Extend to Corner Function.
Thanks!
Trim-Extend Script.dyn (4.6 KB)Python Block Code:
import clr
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import *
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
uiapp = DocumentManager.Instance.CurrentUIApplication
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
elements = [UnwrapElement(i) for i in IN[0]]
pCmd = RevitCommandId.LookupPostableCommandId(PostableCommand.TrimOrExtendToCorner)
TrimExtend = uiapp.PostCommand(pCmd)
for i in elements:
elementIdList = List[Autodesk.Revit.DB.ElementId]()
elementIdList.Add(i.Id)
sel = uidoc.Selection.SetElementIds(elementIdList)
OUT = "Complete"
#Assign your output to the OUT variable.