# ISelectionFilter in Python Script not working on RVT2023/CPython3 but working on RVT2021/IronPhyton 2

**URL:** <https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [April 17, 2024, 3:36pm UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168 "2024-04-17T15:36:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiagofrbr](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tiagofrbr](https://forum.dynamobim.com/u/tiagofrbr)\
**Post date:** [April 17, 2024, 3:36pm UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/1 "2024-04-17T15:36:54Z")

</div>

Hi!  
Why this script is not working on CPython3? Any workaround?

```auto
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

class MySelectionFilter(ISelectionFilter):
	def __init__ (self):
		pass
	def AllowElement(self, element):
		if element.Category.Name == "Walls":
			return True
		else:
			return False
	def AllowReference(self, element):
		return False

selection_filter = MySelectionFilter()

walls = uidoc.Selection.PickElementsByRectangle(selection_filter)
OUT = walls

```

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [April 17, 2024, 3:47pm UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/2 "2024-04-17T15:47:45Z")

</div>

Hi,

No work arounds I’m afraid, ISelection doesn’t work in CPython3… All you can do is find another selection method / use another coding language. Hopefully the shift to PythonNet3 will fix them.

Mark

---

<div class="post-metadata">

**Author:** ![tiagofrbr](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tiagofrbr](https://forum.dynamobim.com/u/tiagofrbr)\
**Post date:** [April 17, 2024, 4:49pm UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/3 "2024-04-17T16:49:18Z")

</div>

What another coding language do you suggest? Is it possible to do inside Dynamo?

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [April 19, 2024, 9:44am UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/4 "2024-04-19T09:44:33Z")

</div>

Hey,

I believe the recommended solution is to build a Zero-Touch node using C sharp, it is still possible to install IronPython2.7 but that is not recommended due to security concerns. The Dynamo roadmap has better integration as ‘under consideration’ [Roadmap - Dynamo BIM](https://dynamobim.org/roadmap/) feel free to add to the voices raising this as a priority.

Apologies for not having a better suggestion ☹

Mark

---

<div class="post-metadata">

**Author:** ![tiagofrbr](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tiagofrbr](https://forum.dynamobim.com/u/tiagofrbr)\
**Post date:** [April 19, 2024, 2:22pm UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/5 "2024-04-19T14:22:24Z")

</div>

Ok! Thanks a lot @Mark.Ackerley!

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [April 20, 2024, 8:48am UTC](https://forum.dynamobim.com/t/iselectionfilter-in-python-script-not-working-on-rvt2023-cpython3-but-working-on-rvt2021-ironphyton-2/100168/6 "2024-04-20T08:48:23Z")

</div>

Ironpython3 can be an solution too
