<?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: Export several bRepBodies into one stl file in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12527813#M2108</link>
    <description>&lt;P&gt;Well, thank you for your reply.&lt;BR /&gt;But I do hope that Fusion API can support exporting bRepBodies.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2024 23:27:24 GMT</pubDate>
    <dc:creator>NuofanQiu</dc:creator>
    <dc:date>2024-01-29T23:27:24Z</dc:date>
    <item>
      <title>Export several bRepBodies into one stl file</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12517371#M2106</link>
      <description>&lt;P&gt;In Fusion360 API, it seems that it only support exporting geometry which to be 'an Occurrence, the root Component, or a BRepBody'.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NuofanQiu_0-1706089044465.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1317738iC6DA0B3117E2F9B0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NuofanQiu_0-1706089044465.png" alt="NuofanQiu_0-1706089044465.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I want export a BRepBodies into a stl file.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is there any method to do that?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Because I want to use different mesh files for visualization and collision in robotics.&lt;/P&gt;&lt;P&gt;Also, is there any API to access the group object?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NuofanQiu_1-1706089316489.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1317740i06E1EEE6B6540761/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NuofanQiu_1-1706089316489.png" alt="NuofanQiu_1-1706089316489.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Like these two group 'visual' and 'collision' in bodies group?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 09:44:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12517371#M2106</guid>
      <dc:creator>NuofanQiu</dc:creator>
      <dc:date>2024-01-24T09:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Export several bRepBodies into one stl file</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12520355#M2107</link>
      <description>&lt;P&gt;Fusion doesn't support that in the UI, but here's a script that will write all selected bodies into a single STL file. It maintains their current position. The bodies need to be selected before running the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fusion does support exporting a component, which can have any number of bodies. This takes advantage of that by creating a new design, copying the selected bodies into the root component of the new design, and then exporting the root component. It then closes the new design without saving.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface

        # Get the currently selected bodies.
        bodies = []
        tempBRep = adsk.fusion.TemporaryBRepManager.get()
        for selection in ui.activeSelections:
            if isinstance(selection.entity, adsk.fusion.BRepBody):
                # Create a temporary B-Rep copy of the body and add it to the list.
                # Creating a copy maintains the current position of the body.
                bodies.append(tempBRep.copy(selection.entity))

        # Create a new design.
        newDoc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des: adsk.fusion.Design = newDoc.products.itemByProductType('DesignProductType')

        # Make it a direct modeling design. No parametrics are needed so this is faster.
        des.designType = adsk.fusion.DesignTypes.DirectDesignType

        # Add the bodies to the root component of the new design.
        root = des.rootComponent
        for body in bodies:
            root.bRepBodies.add(body)

        # Export the root component as STL.
        exportMgr = des.exportManager
        stlOptions = exportMgr.createSTLExportOptions(root, 'C:/Temp/MultiBody.stl')
        stlOptions.sendToPrintUtility = False
        exportMgr.execute(stlOptions)

        # Close the document, without saving.
        newDoc.close(False)

        ui.messageBox('Finished.')       
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 16:31:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12520355#M2107</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2024-01-25T16:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Export several bRepBodies into one stl file</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12527813#M2108</link>
      <description>&lt;P&gt;Well, thank you for your reply.&lt;BR /&gt;But I do hope that Fusion API can support exporting bRepBodies.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 23:27:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/export-several-brepbodies-into-one-stl-file/m-p/12527813#M2108</guid>
      <dc:creator>NuofanQiu</dc:creator>
      <dc:date>2024-01-29T23:27:24Z</dc:date>
    </item>
  </channel>
</rss>

