SetLineStyleID to list of Filled Regions

Appreciate in advance any help that people have, I’m on my third week of Dynamo and third day of using Python nodes :grimacing:

I have a script to automate setting up interior elevation sheets, the last major hurdle is getting the linestyle set in the “donut” filled region that hides the adjacent walls etc. It’s important that this be a filled region, not a crop override. The regions are outputted as list, and inputting it into Filled Region Linstyle node from Maco4Bim and GeniusLoci without success. I also tried using a python script from Jean from the below thread, but only change the active view, or all regions of the type, but not a specific list of regions.
https://forum.dynamobim.com/t/line-styles-in-filled-region/33998

I’ve attempted to adapt the python script from the above to iterate the SetLineStyleID over the list of regions, but I get the error ElementId object has no attribute ‘SetLineStyleID’. How do I get the Filled Regions elements to use the SetLineStyleID method? Or is this breaking in some other way?

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

frList = IN[0]
lineId = UnwrapElement(IN[1]).Id

res = []

TransactionManager.Instance.EnsureInTransaction(doc)

i=0
for i in range(0,len(frList)):
       frtId = UnwrapElement(frList[i]).Id
       frtId.SetLineStyleID(lineId)
       res.append(frtId)
       i += 1

TransactionManager.Instance.TransactionTaskDone()

OUT = res


Crop LW Attempts.dyn (94.5 KB)
Int Elev Revit.rvt (1.2 MB)

The code is trying to change an ElementId property that doesn’t exist
To simplify the code you can iterate over a list in python
There is also a typo as the method is SetLineStyleId() and indenting is not correct in your posted code with 7 spaces instead of 4

Try this (code has not been tested in Revit)

frList = UnwrapElement(IN[0])
lineId = UnwrapElement(IN[1]).Id

res = []
TransactionManager.Instance.EnsureInTransaction(doc)

for fr in frList:
    fr.SetLineStyleId(lineId)
    res.append(fr.Id)

TransactionManager.Instance.TransactionTaskDone()
1 Like

Worked great thank you!!!

1 Like