I would be glad if i can be assisted with this challenge. All looks perfect to me, but i get his error after running. “A transaction or sub-transaction was opened but not closed. All changes to the active document made by External Command will be discarded.”
Heres the code below:
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from curveactions import beam_vector
from curveactions import maxminPoint
# Get active user document, selection and views
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
sel = uidoc.Selection.PickObjects(Selection.ObjectType.Element, 'Choose elements')
views = FilteredElementCollector(doc).OfClass(View).ToElements()
# Get relevant view template
for view in views:
if view.IsTemplate == True:
if view.Name == "RCL - Beam Elevation View":
viewTemplate = view.Id
# List of selected beams
chosen_beams = [doc.GetElement(elId) for elId in sel]
# extension of min and max of boundingbox
endTrans = XYZ(-0.6, -0.15, 0.9)
startTrans = XYZ(0.6, 0.15, -0.3)
# Get curves and vectors from beams
Curves = beam_vector(chosen_beams)[2]
CurvesVector = beam_vector(chosen_beams)[3]
#Get maximum and minimum point from selected beams
minPoint = (maxminPoint(Curves, CurvesVector)[0]) + endTrans
maxPoint = (maxminPoint(Curves, CurvesVector)[1]) + startTrans
#Create new boundingbox from max n min points
newBB = BoundingBoxXYZ()
newBB.Min = minPoint
newBB.Max = maxPoint
#Create section
t = Transaction(doc, 'Create Section')
t.Start()
beamsection = CreateSection(doc, viewTemplate, newBB)
t.Commit()