<?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: Create a Template from a operation using Fusion 360 Python API in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329541#M2611</link>
    <description>&lt;P&gt;Hi -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAMTemplate.createFromOperations takes a list of operations, so you need to pass it as "[operation]".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeff&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 10:31:01 GMT</pubDate>
    <dc:creator>jeff.pek</dc:creator>
    <dc:date>2023-10-25T10:31:01Z</dc:date>
    <item>
      <title>Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329425#M2610</link>
      <description>&lt;P&gt;I am not sure what I am doing wrong but I cannot seem to export Templates from operations for fusion using the API.&lt;/P&gt;&lt;P&gt;Here is the script I am trying:&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, adsk.cam

def save_template():
    # Get the application
    app = adsk.core.Application.get()

    # Get the active document
    doc = app.activeDocument

    # From the Products collection on the active document, get the CAM Product
    cam :adsk.cam.CAM = doc.products.itemByProductType('CAMProductType')

    # Get the first setup.
    setup = cam.setups.item(0)

    # Get the first operation.
    operation = setup.operations.item(0)
    
    # generate the Cam Template
    returnValue = adsk.cam.CAMTemplate.createFromOperations(operation)
    
    # Save the template to a file
    returnValue.save('C:\\file.camtemplate')  # Change this to your desired file path

# Call the function
save_template()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the &lt;STRONG&gt;&lt;A title="CAMTemplate" href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-50C29F54-B2C5-444F-BEF3-2F1A64707383" target="_blank" rel="noopener"&gt;CAMTemplate&lt;/A&gt; &lt;/STRONG&gt;Object to generate templates.&lt;/P&gt;&lt;P&gt;I was also trying to give it a operation list but then Fusion just fully cashed with no error.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:36:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329425#M2610</guid>
      <dc:creator>enervino</dc:creator>
      <dc:date>2023-10-25T09:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329541#M2611</link>
      <description>&lt;P&gt;Hi -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAMTemplate.createFromOperations takes a list of operations, so you need to pass it as "[operation]".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 10:31:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329541#M2611</guid>
      <dc:creator>jeff.pek</dc:creator>
      <dc:date>2023-10-25T10:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329586#M2612</link>
      <description>&lt;P&gt;OK here is the changes I made, Seems to work now thanks, I think I was having issues with separating setup.operations and a list of operation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        # Get the first operation.
        operation = setup.operations.item(0)

        #create a list of operations then add an operation to it
        operations = []
        operations.append(operation)

        # generate the Cam Template
        returnValue = adsk.cam.CAMTemplate.createFromOperations(operations)

        # Save the template to a file
        returnValue.save('C:\\c#\\#python\\1Test\\file.f3dhsm-template')  # Change this to your desired file path&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 10:59:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329586#M2612</guid>
      <dc:creator>enervino</dc:creator>
      <dc:date>2023-10-25T10:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329716#M2613</link>
      <description>&lt;P&gt;Sure, that works. It would be even easier to just put square brackets around the "operation" argument in the call, but what you have does the equivalent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 11:54:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329716#M2613</guid>
      <dc:creator>jeff.pek</dc:creator>
      <dc:date>2023-10-25T11:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329968#M2614</link>
      <description>&lt;P&gt;I am not too familiar with Python syntax, it is all a bit strange to me. anyway, it seems if you put something the API does not like into&amp;nbsp;returnValue.save('here') like an invalid directory or an existing file name, then fusion full crashes without warning, so sanitize that input (fusion should probably wanna look into this too because you would expect an exception throw there, not a full crash)&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 13:18:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12329968#M2614</guid>
      <dc:creator>enervino</dc:creator>
      <dc:date>2023-10-25T13:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Template from a operation using Fusion 360 Python API</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12330071#M2615</link>
      <description>&lt;P&gt;Agreed. Thanks for pointing that out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Jeff&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 13:43:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/create-a-template-from-a-operation-using-fusion-360-python-api/m-p/12330071#M2615</guid>
      <dc:creator>jeff.pek</dc:creator>
      <dc:date>2023-10-25T13:43:50Z</dc:date>
    </item>
  </channel>
</rss>

