findBRepUsingPoint is not returning values as expected

findBRepUsingPoint is not returning values as expected

karolis.s
Advocate Advocate
400 Views
2 Replies
Message 1 of 3

findBRepUsingPoint is not returning values as expected

karolis.s
Advocate
Advocate

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?
 

0 Likes
401 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

I started looking at this but am confused by your description. First, you provided some files and some code but not enough information to reproduce the problem. What points did you use, and what are you hoping to find? You also referred to a search vector, but I don't see that in your code and I don't understand how that is relevant with the findBRepUsingPoint method.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

karolis.s
Advocate
Advocate

Hello, sorry for the confusion.

This is the sample script I am trying to use:
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-6fa682bf-d25e-45b8-8c78-f14451a4fdb8

It has 'getPocketBottomFaces' function which should return pocket bottom faces.

 

 # search the bottom face breps using the points of the boundary
                pocketBottomFaces = getPocketBottomFaces(pocketComponent, points)


Also this sample has

# pocket search vector: only look for pockets from top view: visible and machinable from Z+
        pocketSearchVector = adsk.core.Vector3D.create(0, 0, -1)


So this sample is working correctly with this search vector, but when I do change this vector to search for bottom faces 'pocketSearchVector = adsk.core.Vector3D.create(0, 0, 1)' it doesn't return any faces. 

The first one file sample is creating operations as expected. Top pockets
The second one file sample is not returning pocketBottomFaces from this function (you have to change search vector in second sample). Bottom pockets

0 Likes