Export flat patterns to DXF - getting InternalValidationError : smData

Export flat patterns to DXF - getting InternalValidationError : smData

gvisca44
Advocate Advocate
720 Views
4 Replies
Message 1 of 5

Export flat patterns to DXF - getting InternalValidationError : smData

gvisca44
Advocate
Advocate

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.

0 Likes
Accepted solutions (1)
721 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor
Accepted solution

You've run into a bug with the API. It should be returning None in this case and needs to be fixed. I'll see that a bug is filed.

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

gvisca44
Advocate
Advocate
Thanks Brian.

For reference in future .. is can you tell me how bugs are logged ?
0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor

Bugs are logged internally by Autodesk. I still have some connections at Autodesk. 😁

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

gvisca44
Advocate
Advocate

For future reference - this BUG was resolved in the January 2023 release. 

0 Likes