<?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 Output Specific File, as STP, to &amp;quot;C:\Windows\Temp\&amp;quot; in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/output-specific-file-as-stp-to-quot-c-windows-temp-quot/m-p/9903540#M10004</link>
    <description>&lt;P&gt;Can anybody help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following Fusion 360 script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import adsk.core, adsk.fusion, traceback&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import os.path, sys&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def run(context):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ui = None&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;try:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;app = adsk.core.Application.get()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui = app.userInterface&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;product = app.activeProduct&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;design = adsk.fusion.Design.cast(product)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;allComps = design.allComponents&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;scriptDir = os.path.dirname(os.path.realpath(__file__))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exportMgr = design.exportManager&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for comp in allComps:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;compName = comp.name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fileName = scriptDir + "/" + compName&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;stpOptions = exportMgr.createSTEPExportOptions(fileName, comp)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exportMgr.execute(stpOptions)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;except:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if ui:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody update the above script so that it only exports a file called "&lt;STRONG&gt;Sprocket&lt;/STRONG&gt;" to "&lt;STRONG&gt;C:\Windows\Temp\&lt;/STRONG&gt;"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
    <pubDate>Mon, 30 Nov 2020 08:37:52 GMT</pubDate>
    <dc:creator>isocam</dc:creator>
    <dc:date>2020-11-30T08:37:52Z</dc:date>
    <item>
      <title>Output Specific File, as STP, to "C:\Windows\Temp\"</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/output-specific-file-as-stp-to-quot-c-windows-temp-quot/m-p/9903540#M10004</link>
      <description>&lt;P&gt;Can anybody help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following Fusion 360 script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import adsk.core, adsk.fusion, traceback&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import os.path, sys&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def run(context):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ui = None&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;try:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;app = adsk.core.Application.get()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui = app.userInterface&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;product = app.activeProduct&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;design = adsk.fusion.Design.cast(product)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;allComps = design.allComponents&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;scriptDir = os.path.dirname(os.path.realpath(__file__))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exportMgr = design.exportManager&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for comp in allComps:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;compName = comp.name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fileName = scriptDir + "/" + compName&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;stpOptions = exportMgr.createSTEPExportOptions(fileName, comp)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;exportMgr.execute(stpOptions)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;except:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if ui:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody update the above script so that it only exports a file called "&lt;STRONG&gt;Sprocket&lt;/STRONG&gt;" to "&lt;STRONG&gt;C:\Windows\Temp\&lt;/STRONG&gt;"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 08:37:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/output-specific-file-as-stp-to-quot-c-windows-temp-quot/m-p/9903540#M10004</guid>
      <dc:creator>isocam</dc:creator>
      <dc:date>2020-11-30T08:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Output Specific File, as STP, to "C:\Windows\Temp\"</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/output-specific-file-as-stp-to-quot-c-windows-temp-quot/m-p/9918815#M10005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well done, you're super close! I've made some small modification:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We'll need to be looking for the correct component so I've added an &lt;EM&gt;if()&lt;/EM&gt; statement. It checks if the name is in a list of names that should be exported. (The list contains variations of the name 'Sprocket' but could contain any name.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also took the liberty of adding a unique identifier to the name in case there are more components named sprocket. (Just remove the &lt;EM&gt;+ "_" + comp.id&lt;/EM&gt; if you don't like that.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've removed the &lt;EM&gt;scriptdirectory&lt;/EM&gt; parameter; it was looking for the directory of the script as the export destination. Since you were looking for a fixed location I've replaced it with the &lt;EM&gt;folder&lt;/EM&gt; parameter.&amp;nbsp; Note that the notation uses forward slashes instead of backward slashes like Windows does!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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
       
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        allComps = design.allComponents
        exportMgr = design.exportManager

        for comp in allComps:
            acceptedNames = ["Sprockets", "sprockets", "Sprocket", "sprocket"]
            if comp.name in acceptedNames :
                folder = "C:/Windows/Temp/"
                fileName = folder + comp.name + "_" + comp.id
                stpOptions = exportMgr.createSTEPExportOptions(fileName, comp)
                exportMgr.execute(stpOptions)

    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;You should be able to run the above code as a script!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Dec 2020 10:46:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/output-specific-file-as-stp-to-quot-c-windows-temp-quot/m-p/9918815#M10005</guid>
      <dc:creator>PinRudolf</dc:creator>
      <dc:date>2020-12-06T10:46:08Z</dc:date>
    </item>
  </channel>
</rss>

