Copy selected filters and filter overrides between views and view templates

Hello all,
I am trying to copy selected filters and filter overrides between views and view templates using datashape package, everything seems to be working fine except that the final output of the graph only copy overrides to the first selected filter and not the rest.
Images and graph attached.
Home.dyn (32.1 KB)


Many thanks in advance.

2 Likes

Hmm, the following List@Level changes and addition of View.Filters seems to help.

I cannot speak as to how it would behave with multiple views selected though. That might take some more investigation.

Hello John,
Not sure why in my end it does not work, the node View.SetFilterOverrides only give me one item in the out list.
However when I used the graph you explained us the other day the number of items in the out list is the same as the number of filters you copy across.
I thought it was my dynamo version but it isnt I have tried with 1.3.2 and 1.3.3


Attached both results.

I have modified the lacing to longest and it is working now…:hushed:
I do not understand why in my end, or why in this graph and not in the other one I have to have a different lacing, is this a glitch???
Many thanks for your support.

2 Likes

I couldn’t get either to work! I wrote my own code… It needs error catching and to work for lists of views, but hopefully it helps others…

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

viewOrig = UnwrapElement(IN[0])
viewTarg = UnwrapElement(IN[1])

overrides = []
filters = viewOrig.GetFilters()

filterElemIds = []
for filter in filters:
	fel = doc.GetElement(filter)
	filterElemIds.append(fel.Id)
	
for filterElemId in filterElemIds:
	overrides.append(viewOrig.GetFilterOverrides(filterElemId))

result = []

count = 0
TransactionManager.Instance.EnsureInTransaction(doc)
for filterElemId, override in zip(filterElemIds, overrides):
	viewTarg.SetFilterOverrides(filterElemId, override)
	result.append('success')

TransactionManager.Instance.TransactionTaskDone()


OUT = result

2 Likes

@Mark.Ackerley I have both copy and retyped your python into my Dynamo script but it seem to be unable to work would you know why?

Hi BIMadmin,

I’m quite new to Dynamo.
I downloaded your Home.dyn node and tried to apply to my file, in order to copy view filter overrides form one view template to others.
After modifying the lacing to longest as you mentioned,I managed to have it copying filters+overrides from one view template to another.
When it comes to do the same to multiple view templates, it actually copies filter+overrides (pattern and line colors) just to the first one view template, the others just get the filters without the overrides. Is there a way to have it to copy filters with the overrides to multiple view templates at once?
One last thing, in elements.name node it gives me this output (but it works the same): Warning: Internal error, please report: Dereferencing a non-pointer
I attach the node so that you can check it out
Thanks for having shared!
Filters+Overrides OK.dyn (69.4 KB)

1 Like