Hello, I’m trying my hand at Selection filter, I copied a large part of the code from Mr. ChuongMep (thanks to him)
In the following gif you see that the filtering of the verticals poses a problem (I think it is linked to the tolerance on the vector component but I am not absolutely sure)
how do you handle this in python

import sys
import clr
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
dir = IN[1]
if dir:
cx=1
else:
cx=0
#Thanks to Mr. Chuongmep for the following code
class MySelectionFilter(ISelectionFilter):
def __init__(self):
pass
def AllowElement(self, element):
if element.Location.Curve.Direction.X==cx or element.Location.Curve.Direction.X==-cx:
return True
else:
return False
flag = IN[0]
if flag:
selection_filter = MySelectionFilter()
elt = uidoc.Selection.PickElementsByRectangle(selection_filter)
OUT = elt
thanks in advance
Sincerely
christian.stan
