findBRepUsingPoint is not returning values as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I have spent few hours by trying to debug a method founded in Fusion360 CAM API samples, but without any result.
I have tried to play with PROXIMITY_TOLERANCE constant, but I couldn't achieve expected result. Btw in what units PROXIMITY_TOLERANCE is defined? Cm?
I have tried to change pocketBottomZ value to negative. Interesting thing that both top and bottom open blind pockets has a positive value. Shouldn't bottom pocket z values be negative instead of positive?
This is the method which does not return expected values for me for bottom search vector:
def getPocketBottomFaces(component: adsk.fusion.Component, points: list[adsk.core.Point3D]) -> list[adsk.fusion.BRepFace]:
''' Search the pocket bottom faces using the provided points '''
# search the bottom face breps using the provided points of the boundary
pocketBottomFaces: list[adsk.fusion.BRepFace] = []
# define the Z value of the pocket bottom using a recognized boundary point
TOLERANCE = 2
pocketBottomZ = -round(points[0].z, TOLERANCE)
print('Pocket bottom z: ' + str(pocketBottomZ))
for point in points:
breps = component.findBRepUsingPoint(point, adsk.fusion.BRepEntityTypes.BRepFaceEntityType, PROXIMITY_TOLERANCE, True)
for brep in breps:
# cast so we have a nice typed variable
brep = adsk.fusion.BRepFace.cast(brep)
# filter to only find the flat faces (not the pocket walls)
if round(brep.boundingBox.minPoint.z, TOLERANCE) == pocketBottomZ and round(brep.boundingBox.maxPoint.z, TOLERANCE) == pocketBottomZ:
if not brep in pocketBottomFaces:
pocketBottomFaces.append(brep)
return pocketBottomFaces
I have only added round function to round z values, because sometimes they do not match.
It is working correctly for Z+ search vector
pocketSearchTopVector = adsk.core.Vector3D.create(0, 0, -1)
https://a360.co/3MD5ij0
It is not returning any faces when I do change search vector to Z- direction
pocketSearchBottomVector = adsk.core.Vector3D.create(0, 0, 1)
https://a360.co/472RqqD
Any ideas?