Was in the process of writing add-in that processes sheet metal components.
Found that component.flatPattern.bendLinesBody and component.flatPattern.extentLinesBody against a component with no bends causes crash. Seems like component.flatPattern.bodies also causes a crash.
Crash report 336849264 sent.
Glenn.
A crash is never good, and even when you do something wrong, the API should fail and never crash. However, I created a very simple test case where I made a new design that contained a sheet metal part, inserted it into a new design, and then used the API to call the bendLinesBody property. I'm not seeing a crash, and it returns the body, so there must be something else that's causing it to crash. Can you post a test case and the code that reproduces the crash?
Will do @BrianEkins.
Just to be clear - because I mis-interpreted the symptoms initially.
The crash appears on sheet metal components that dont have bends (where initially I thought it was on linked components). Just happened that my original tests included linked components that didnt have bends.
As requested. The embedded image (which I have also included as attachment just in case) shows the progression of the script to the point of crash.
import adsk.core
import adsk.fusion
import traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
if not design:
ui.messageBox('No active Fusion design', 'No Design')
return
allComps: adsk.fusion.Components = design.allComponents
for component in allComps:
for body in component.bRepBodies:
if body.isSheetMetal:
msg = f'Component \t "{component.name}" has sheet metal body'
app.log(msg)
adsk.doEvents()
bendLinesBody = component.flatPattern.bendLinesBody
for BRepEdge in bendLinesBody.edges:
(retval, isBendUp, bendAngle) = component.flatPattern.getBendInfo(BRepEdge)
msg = f'\tretval:{retval} isBendUp:{isBendUp} bendAngle:{bendAngle}'
app.log(msg)
adsk.doEvents()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Thank you for providing the f3z + image, I was able to reproduce this and identify the issue. Will get this fixed!
Unfortunately we don't have any public facing bug fix tracking, this specific fix should be out within the next month or so though.
In the meantime one workaround I can suggest is to compare the flatPattern.flatBody.faces.count (shouldn't crash) to the component.bRepBodies[0].faces.count - the counts are equal, then that means there are no bends in the flatpattern.
Can't find what you're looking for? Ask the community or share your knowledge.