<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10063208#M9477</link>
    <description>&lt;P&gt;It looks like it may be linked to the full pathname being too long. I would like if someone in the known could confirm, and also if it would be possible to have an helping exception, rather than the quite cryptic "success".&lt;/P&gt;</description>
    <pubDate>Sat, 06 Feb 2021 18:22:34 GMT</pubDate>
    <dc:creator>Le_Bear</dc:creator>
    <dc:date>2021-02-06T18:22:34Z</dc:date>
    <item>
      <title>ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10062858#M9476</link>
      <description>&lt;P&gt;Ok I must say, I love it !&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_heart_eyes:"&gt;😍&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I get an error to tell me "success"&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Anyway, this is pretty annoying&amp;nbsp;, as the script stop working, after running properly for a while.&lt;BR /&gt;Here is the exact error I am getting (sorry, repetitive errors trying to upload that tiny image)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the script itself, s it's pretty short:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;#Author-BG
#Description-Copy bodies from a full assembly into a single component, to make it easier to export a STL

# The goal is to copy bodies from a full assembly into a new component, so that it will be possible
# to export as STL from Fusion with a common origin (and axis)

# Beginning on 23/2/2020 :59 by BG

# Now the script DO NOT copy bodies, just export them as STL, only if the component is visible


import adsk.core, adsk.fusion, traceback

# Create a collection to store our bodies 
sourceBodies = adsk.core.ObjectCollection.create()

folder = "C:/Users/bgros/Documents/Rosetta/Machine Nicolas/ApiExport"
   
def traverse(occurences):
    # recursive method to get all bodies from components and sub-components
    for occ in occurences: 
        visiFlag = occ.isLightBulbOn                         
        bodies = occ.bRepBodies          
        for bod in bodies:
            if visiFlag:
                bod.name = occ.fullPathName                
                sourceBodies.add(bod) 
                adsk.doEvents()  
                visiFlag = False

        if occ.childOccurrences:
            traverse(occ.childOccurrences)
    
def run(context):
    ui = None   
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        

        # Get active design
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        if not design:
            ui.messageBox('It is not supported in current workspace, please change to MODEL workspace and try again.')
            return

        # History must be captured for this to work
        if design.designType == adsk.fusion.DesignTypes.DirectDesignType:
            design.designType = adsk.fusion.DesignTypes.ParametricDesignType

 
        # Get root component in this design
        rootComp = design.rootComponent
               
        # Get all Components below root       
        occs = rootComp.occurrences

        # add all bodies from all components in the collection 
        traverse(occs)

        # # create the new component , adding "for STL Export" to the name       
        # newComp = occs.addNewComponent(adsk.core.Matrix3D.create())                
        # newComp.component.name = rootComp.name + " for STL Export"
        adsk.doEvents() 
        # copy paste ALL bodies to the new component
        #newComp.component.features.copyPasteBodies.add(sourceBodies)
        for oneBody in sourceBodies:
            #oneBody.name = rootComp.name + " " + oneBody.name    
            # newComp.component.features.copyPasteBodies.add(oneBody)
            # Construct the output filename.
            oneBody.name = oneBody.name.replace(":", "-")
            filename = folder + "/" + oneBody.name + '.stl'            
            # Save the file as STL.
            exportMgr = adsk.fusion.ExportManager.cast(design.exportManager)
            stlOptions = exportMgr.createSTLExportOptions(oneBody, filename)            
            stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementHigh
            stlOptions.isOneFilePerBody = True
            stlOptions.sendToPrintUtility = False
            exportMgr.execute(stlOptions)
            adsk.doEvents() 

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 15:12:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10062858#M9476</guid>
      <dc:creator>Le_Bear</dc:creator>
      <dc:date>2021-02-06T15:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10063208#M9477</link>
      <description>&lt;P&gt;It looks like it may be linked to the full pathname being too long. I would like if someone in the known could confirm, and also if it would be possible to have an helping exception, rather than the quite cryptic "success".&lt;/P&gt;</description>
      <pubDate>Sat, 06 Feb 2021 18:22:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10063208#M9477</guid>
      <dc:creator>Le_Bear</dc:creator>
      <dc:date>2021-02-06T18:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10074664#M9478</link>
      <description>&lt;P&gt;This is a known issue that True is returned even when the translation has failed.&amp;nbsp; Hopefully, it will be addressed soon.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 04:25:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10074664#M9478</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2021-02-11T04:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: ExportManager(stlOptions) RuntimeError: 2 : InternalValidationError : success</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10075832#M9479</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;This is a known issue that True is returned even when the translation has failed.&amp;nbsp; Hopefully, it will be addressed soon.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Translation ? Into an STL, you mean? OK, good to know it is known, not just some mistake from me. Is there any workaround possible ? At least to know what could make it fail.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 14:28:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exportmanager-stloptions-runtimeerror-2-internalvalidationerror/m-p/10075832#M9479</guid>
      <dc:creator>Le_Bear</dc:creator>
      <dc:date>2021-02-11T14:28:27Z</dc:date>
    </item>
  </channel>
</rss>

