Modify Sectionbox.byElements Node

Is their a way to modify this python script to output the newly created section box instead of Success?

import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

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

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

bbox=IN[0]

doc=DocumentManager.Instance.CurrentDBDocument
myview=doc.ActiveView
try:
TransactionManager.Instance.EnsureInTransaction(doc)

newmax=UnwrapElement(bbox.MaxPoint).ToRevitType()
newmin=UnwrapElement(bbox.MinPoint).ToRevitType()
newbox=BoundingBoxXYZ()
newbox.Max=newmax
newbox.Min=newmin

z=myview.SetSectionBox(newbox)

TransactionManager.Instance.TransactionTaskDone()

OUT = "Success!"

except:
OUT=“Failed miserably…”

@ZJRODGERS, I suppose that you should change your python output to OUT = newbox instead of OUT = “success”, and remove the Output node from your graph.

sorry i know nothing about python… thank you for the help

Just make sure to keep the ‘failed miserably’ as the alternate output when it doesn’t work as it makes me chuckle.

1 Like