Bring to Front/Send to Back Detail Items

Following up on this old post: Bring forward / send back (detail items)

This was working for me up until today. Anyone have an idea what could have happened?

Bring to Front Break Line.dyn (20.1 KB)

Now when I run it, I get this error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 32, in
AttributeError: ‘FamilyInstance’ object has no attribute ‘ID’

The IronPython code is

"

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

clr.AddReference(‘System’)
from System.Collections.Generic import List

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

doc = DocumentManager.Instance.CurrentDBDocument

#Converting input from Dynamo to Revit
mylist = UnwrapElement(IN[0])

#Bring detail item to front in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for i in range(0,len(mylist)):
viewmatch = mylist[i]
v = viewmatch[1]
elem = viewmatch[0]
btf = DetailElementOrderUtils.BringToFront(doc,v,elem.Id)

TransactionManager.Instance.TransactionTaskDone()

OUT = btf

";

Can you show an image of the graph with the output visible from the list of items being fed into it? You may have something in the “view” that you can’t do this on and it is throwing this error.

1 Like

I do have a view with no name, which is odd.

Tried it again with a new project with just two views and a different detail element. Still getting the same error.

Capture2

ETA: Figured it out. The detail item cannot be in a group if you want to “bring to front” or “send to back”.

Simplified it a bit and upgraded to Dynamo 2.0 but now getting error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 31, in
Exception: The element detailElementId is not a detail element.
Parameter name: detailElementId

Revised Python script:

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

clr.AddReference(‘System’)
from System.Collections.Generic import List

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

doc = DocumentManager.Instance.CurrentDBDocument

#Converting input from Dynamo to Revit
mylist = UnwrapElement(IN[0])

#Send detail item to back in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for i in range(0,len(mylist)):
viewmatch = mylist[i]
v = viewmatch[1]
elem = viewmatch[0]
btf = DetailElementOrderUtils.BringToFront(doc,v,elem.Id)

TransactionManager.Instance.TransactionTaskDone()

OUT = btf

Capture3

1 Like