Add Filters to 3d view template

Hello Everyone,

First of all, sorry for my bad English. It’s not my native language.

I have not knowledge of python language but watching videos and others topics here in en forum. I created a custom node with python.
This node allows to modify all overrides filters for a view template. It works perfect for floorplans, ceiling plans, elevations and sections. The problem is for 3d view template. It has a mistake and I am stuck as to how to solved it.

Here is my dynamo script:
filterOverrides.dyn (35.9 KB)

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI 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
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

### INPUTS
view = UnwrapElement(IN[0])
filter = UnwrapElement(IN[1])
PLpat = UnwrapElement(IN[2])
PLcolor = IN[3]
PLgrosor = IN[4]
PFpat = UnwrapElement(IN[5])
PFcolor = IN[6]
PFvis = IN[7]
PBpat = UnwrapElement(IN[8])
PBcolor = IN[9]
PBvis = IN[10]
PPtrans = IN[11]
CLpat = UnwrapElement(IN[12])
CLcolor = IN[13]
CFpat = UnwrapElement(IN[14])
CFcolor = IN[15]
CFvis = IN[16]
CBpat = UnwrapElement(IN[17])
CBcolor = IN[18]
CBvis = IN[19]
Tramado = IN[20]

def ToRevitColor(dynamoColor):
    return Color(dynamoColor.Red, dynamoColor.Green, dynamoColor.Blue)


TransactionManager.Instance.EnsureInTransaction(doc)

ovg = DB.OverrideGraphicSettings()

if PLpat == None:
    pass
else:
    ovg.SetProjectionLinePatternId(PLpat.Id)
if PLcolor == None:
    pass
else:    
    ovg.SetProjectionLineColor(ToRevitColor(PLcolor))
if PLgrosor == None:
    pass
else:
    ovg.SetProjectionLineWeight(PLgrosor)
if PFpat == None:
    pass
else:
    ovg.SetSurfaceForegroundPatternId(PFpat.Id)
if PFcolor == None:
    pass
else:
    ovg.SetSurfaceForegroundPatternColor(ToRevitColor(PFcolor))
if PFvis == None:
    pass
else:
    ovg.SetSurfaceForegroundPatternVisible(PFvis)
if PBpat == None:
    pass
else:
    ovg.SetSurfaceBackgroundPatternId(PBpat.Id)
if PBcolor == None:
    pass
else:
    ovg.SetSurfaceBackgroundPatternColor(ToRevitColor(PBcolor))
if PBvis == None:
    pass
else:
    ovg.SetSurfaceBackgroundPatternVisible(PBvis)
if PPtrans == None:
    pass
else:
    ovg.SetSurfaceTransparency(PPtrans)
if CLpat == None:
    pass
else:
    ovg.SetCutLinePatternId(CLpat.Id)
if CLcolor == None:
    pass
else:    
    ovg.SetCutLineColor(ToRevitColor(CLcolor))
if CFpat == None:
    pass
else:
    ovg.SetCutForegroundPatternId(CFpat.Id)
if CFcolor == None:
    pass
else:
    ovg.SetCutForegroundPatternColor(ToRevitColor(CFcolor))
if CFvis == None:
    pass
else:
    ovg.SetCutForegroundPatternVisible(CFvis)
if CBpat == None:
    pass
else:
    ovg.SetCutBackgroundPatternId(CBpat.Id)
if CBcolor == None:
    pass
else:
    ovg.SetCutBackgroundPatternColor(ToRevitColor(CBcolor))
if CBvis == None:
    pass
else:
    ovg.SetCutBackgroundPatternVisible(CBvis)
if Tramado == None:
    pass
else:
    ovg.SetHalftone(Tramado)


view.SetFilterOverrides(filter.Id, ovg)


TransactionManager.Instance.TransactionTaskDone()


Thanks in advanced.