# Need help with Python - FillPatternElement

**URL:** <https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620>\
**Category:** DesignScript\
**Tags:** python\
**Created:** [February 1, 2023, 10:47am UTC](https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620 "2023-02-01T10:47:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melanie\_V](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Melanie\_V](https://forum.dynamobim.com/u/Melanie_V)\
**Post date:** [February 1, 2023, 10:47am UTC](https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620/1 "2023-02-01T10:47:21Z")

</div>

Hello!  
I have a problem with my script Python. I need to collect the solid pattern to apply it in a view. But I have an error, and I don’t see where it’s come from.  
I find this code on different forum:  
patternsList = FilteredElementCollector(doc).OfClass(FillPatternElement)  
solidPatternID = 0  
for p in patterns :  
pat = p.GetFillPattern()  
if pat.IsSolidFill == True:  
solidPatternID = p.Id

But Dynamo tell me:  
“Avertissement:IronPythonEvaluator.EvaluateIronPythonScript l’opération a échoué.  
Traceback (most recent call last):  
File “”, line 73, in   
Exception: Input type(Revit.Elements.FillPatternElement) is not a recognized Revit API type  
Parameter name: type”

Do you have an idea to resolve that ?  
Thank you for your help  
PS: Sorry for my bad english (it’s not easy for me to explain my problem with a different language)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [February 1, 2023, 11:00am UTC](https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620/2 "2023-02-01T11:00:44Z")

</div>

@Melanie_V ,

can you paste your code ?

```auto
</>

```

```auto
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure 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

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

OUT = element

```

---

<div class="post-metadata">

**Author:** ![Melanie\_V](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Melanie\_V](https://forum.dynamobim.com/u/Melanie_V)\
**Post date:** [February 1, 2023, 1:00pm UTC](https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620/3 "2023-02-01T13:00:15Z")

</div>

Thanks for your answer.  
There is my code :

```auto
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
import Autodesk

clr.AddReference('RevitNodes')
from Revit.Elements import *

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

from System.Collections.Generic import List

dataEnteringNode = IN
doc = DocumentManager.Instance.CurrentDBDocument

valuesList = IN[0]
paramID_Debut = ElementId(IN[1])
paramID_Fin = ElementId(IN[2])
paramID_Chantier = ElementId(IN[3])
filterNameList = IN[4]
myView = UnwrapElement(IN[5])

optionDuplicate = Autodesk.Revit.DB.ViewDuplicateOption.WithDetailing

paramElem = doc.GetElement(paramID_Debut)
definition = paramElem.GetDefinition()
binding_map = doc.ParameterBindings
binding = binding_map.Item[definition]

category_set = binding.Categories.GetEnumerator()
cat_ids = [cat.Id for cat in category_set]
cat_ids_list = List[ElementId](cat_ids)
cat_ids_valid = ParameterFilterUtilities.RemoveUnfilterableCategories(cat_ids_list)

pStart = ParameterValueProvider (paramID_Debut)
pEnd = ParameterValueProvider (paramID_Fin)
pChantier = ParameterValueProvider (paramID_Chantier)

FiltersList = list(FilteredElementCollector(doc).OfClass(ParameterFilterElement).ToElements())
FiltersName = [i.Name for i in FiltersList]
mesFiltres = []

red = Color(255,0,0)

patternsList = FilteredElementCollector(doc).OfClass(FillPatternElement)
solidPatternID = 0
for p in patterns :
	pat = p.GetFillPattern()
	if pat.IsSolidFill == True:
		solidPatternID = p.Id

TransactionManager.Instance.EnsureInTransaction(doc)

for myValue in valuesList :
	phaseEnCours = filterNameList[0]+str(myValue)
	postPhase = filterNameList[1]+str(myValue)
	
	newViewID = View.Duplicate(myView, optionDuplicate)
	newView = doc.GetElement(newViewID)
	try :
		newView.Name = myView.Name+"_"+str(myValue)
		mesFiltres.Add("Vue créée : "+newView.Name)
	except : 
		mesFiltres.Add("Vue non renommée : "+newView.Name)
	
	if phaseEnCours not in FiltersName :
		xStart_enCours = FilterElementIdRule (pStart, FilterNumericLessOrEqual(), ElementId(myValue))
		xEnd_enCours = FilterElementIdRule (pEnd, FilterNumericGreaterOrEqual(), ElementId(myValue))
		xrule_enCours = []
		xrule_enCours.Add(ElementParameterFilter(xStart_enCours))
		xrule_enCours.Add(ElementParameterFilter(xEnd_enCours))
		ruleList_enCours = List[ElementFilter](xrule_enCours)
		myRule_enCours = LogicalAndFilter(ruleList_enCours)
		filter_current = ParameterFilterElement.Create(doc, phaseEnCours, cat_ids_valid, myRule_enCours)
	else :
		for f in FiltersList:
			if f.Name == phaseEnCours :
				filter_current = f
	newView.AddFilter(filter_current.Id)
	
	over = newView.GetFilterOverrides(filter_current.Id)
	over.SetSurfaceTransparency(0.0)
	over.SetCutForegroundPatternColor(red)
	over.SetSurfaceForegroundPatternColor(red)
	newView.SetFilterOverrides(filter_current.Id,over)
	mesFiltres.Add(phaseEnCours)
		
TransactionManager.Instance.TransactionTaskDone()

OUT = mesFiltres

```

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 1, 2023, 3:28pm UTC](https://forum.dynamobim.com/t/need-help-with-python-fillpatternelement/85620/4 "2023-02-01T15:28:35Z")

</div>

It’s possible that `FillPatterns` are not a valid class for the FEC. You can always get this list in Dynamo using `Element Classes` and `All Elements of Class`.
