I have run into something similar. I have a bit of code (see bottom) where I simply run from DB and I get drastically different run times than importing from pyrevit
Times are right after import and setting up doc/uidoc variables, then at the end of the transaction - Note that the tests are taken after closing and re opening Revit (2022.1 for these tests)
DB import:
0.01596 & 1.1934 (for first run)
0.01599 & 0.2025 (for second run - probably faster due to worksharing not having to check the element out again)
pyrevit import:
1.5015 & 2.7338 (first run)
1.5989 & 1.9700 (second run)
Another weird thing I’ve seen is that the pyrevit imports keep getting longer where DB does not…
1.7228 & 2.0854 (3rd)
1.8115 & 2.1605 (4th)
…
2.4808 & 2.6745 (10th)
…
3.5544 & 3.9016 (20th)
I agree that for the most part, we haven’t seen an issue with importing pyrevit, but I noticed the script was sluggish as I was making it. I wasn’t expecting a script to take upwards of 7 seconds to simply rotate an element. We were hoping to make a dockable pane with some scripts like this to do some quick things that people were needing multiple steps for (for this - creating a section/moving it around and using the rotate tool to get something to rotate)
Now that I think about it, might be a good thing to put into an issue on GitHub?
DB only:
import time
st = time.time()
from math import radians
import Autodesk.Revit.DB as DB
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
print(time.time() - st)
t = DB.Transaction(doc, "Rotate Element (Y-Axis)")
t.Start()
selection = uidoc.Selection.GetElementIds()
# >>>>>>>>>> GET CENTER POINT
elem = doc.GetElement(selection[0])
bounding_box = elem.get_BoundingBox(doc.ActiveView)
point = (bounding_box.Min + bounding_box.Max) / 2
# >>>>>>>>>> AXIS LINE
axis_line = DB.Line.CreateBound(point, point + DB.XYZ.BasisY)
# >>>>>>>>>> ROTATE
DB.ElementTransformUtils.RotateElement(doc, elem.Id, axis_line, radians(90))
t.Commit()
print(time.time() - st)
pyRevit only
import time
st = time.time()
from pyrevit import HOST_APP
from pyrevit.revit import Transaction
from pyrevit import DB
from math import radians
doc = HOST_APP.doc
uidoc = HOST_APP.uidoc
print(time.time() - st)
with Transaction("Rotate Element (Y-Axis)"):
selection = uidoc.Selection.GetElementIds()
# >>>>>>>>>> GET CENTER POINT
elem = doc.GetElement(selection[0])
bounding_box = elem.get_BoundingBox(doc.ActiveView)
point = (bounding_box.Min + bounding_box.Max) / 2
# >>>>>>>>>> AXIS LINE
axis_line = DB.Line.CreateBound(point, point + DB.XYZ.BasisY)
# >>>>>>>>>> ROTATE
DB.ElementTransformUtils.RotateElement(doc, elem.Id, axis_line, radians(90))
print(time.time() - st)