Getting Bend Information Sheet Metal Part

Getting Bend Information Sheet Metal Part

gvisca44
Advocate Advocate
696 Views
3 Replies
Message 1 of 4

Getting Bend Information Sheet Metal Part

gvisca44
Advocate
Advocate

I am working on a script that processes a design and extracts all sorts of component information (for the creation of a purchase order to my supplier).

 

One of the required attributes is the quantity of sheet metal folds/bends. I have happened across the FlatPattern.getBendInfo Method (and ignore my other post for the moment - refer: here).

 

When I run this method - I end up with 4 bends (as in - 4 x BRepEdge)... where my component has only 2 sheet metal folds. I assume there is a topside set of bends and a bottomside set of bends - but how do I know which bends are related to the top and which are related to the bottom ?

bendLinesBody = component.flatPattern.bendLinesBody

for BRepEdge in bendLinesBody.edges:

      (retval, isBendUp, bendAngle) = component.flatPattern.getBendInfo(BRepEdge)
      ##remainder of code##

 

Glenn.

0 Likes
Accepted solutions (1)
697 Views
3 Replies
Replies (3)
Message 2 of 4

BrianEkins
Mentor
Mentor
Accepted solution

You can see in the graphics window that there is a line on both sides of the flat pattern for each bend. It would be nice if the bend information included some additional information to tell you if the input edge is on the top or bottom. However, it's fairly easy to figure out. Here's a modified version of your code. I didn't run it so there could be a syntax error or two but it demonstrates the concept.

 

import math

fp = component.flatPattern
topFaceZ = fp.topFace.pointOnFace.z
bendLinesBody = fp.bendLinesBody
for BRepEdge in bendLinesBody.edges:
    # Check if this edge is in the same Z plane as the top face.
    # Because of issues with floating point comparisons, it uses
    # a tolerance.
    if math.fabs(BRepEdge.pointOnEdge.z - topFaceZ) < 0.00001:
        (retval, isBendUp, bendAngle) = component.flatPattern.getBendInfo(BRepEdge)

 

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

gvisca44
Advocate
Advocate

Marvellous @BrianEkins !!

 

I landed in a similar place mentally ... Anecdotally it appears as though 0,0,0 is x,y=lower left corner/z=top face - so I wondered about using that as a baseline - and finding all edges z=0.  

 

Glenn.

0 Likes
Message 4 of 4

BrianEkins
Mentor
Mentor

I think that will work. I thought maybe a dimple or some other shape that extends out of the flat might change how the part is positioned relative to 0,0,0, but that doesn't seem to make a difference, and it's the top face on the Z zero plane. Even if you use 0, I would still do the comparison within a tolerance.

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