Automating Trim Extend to Corner

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.
1 Like

Hi @nikhilmakan02

It’s worth looking at MEPOver package it covers what your looking for:

4 Likes

Hi Kulkul

Thanks for the reply, I had a look through the Python Script for that node unfortunately its not exactly what I was looking for. I apologise as I have misdirected you with the use of two pieces of duct but where I would like to actually use this is with two beams. At the time I didn’t think it mattered what element it was.

The MEPOver node relies on placing a bend between the two pieces of pipe but with two beams there is no bend to be placed in between.

1 Like