Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
with the recent Fusion API updates exposing sheet metal rules, flat patterns etc. I decided it was high time to finish my script to export all flat patterns in a design to DXF. I have the bulk of the script working, other than iterating the design to choose components that have flat pattern objects.
I initially started iterating:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
for component in design.allComponents
if component.activeSheetMetalRule:
#do something
else:
#do something else
However - where a component is NOT a sheet metal component - I receive the following error:
Failed:
Traceback (most recent call last):
File "D:/Users/Public/G2VDesign_OneDrive/OneDrive - G2V DESIGN PTY LTD/Fusion 360 Tools/Add-ins/G2V Flats2DXF/G2V Flats2DXF.py", line 105, in processComponents
if component.activeSheetMetalRule:
File "C:\Users/gvisc/AppData/Local/Autodesk/webdeploy/production/81ea974ab1a66e3de83fe316ff859f913e6ff720/Api/Python/packages\adsk\fusion.py", line 47671, in _get_activeSheetMetalRule
return _fusion.Component__get_activeSheetMetalRule(self)
RuntimeError: 2 : InternalValidationError : smData
I have since found:
for component in design.allComponents
for body in component.bRepBodies:
if body.isSheetMetal:
#do something
else:
#do something else
...and we are in business !
Is the error above for activeSheetMetalRule correct ? API help indicates I should receive NULL.
Glenn.
Solved! Go to Solution.