<?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: Reorder operations in setup in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12187831#M3106</link>
    <description>&lt;P&gt;Is there a chance it may not be possible?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2023 10:37:17 GMT</pubDate>
    <dc:creator>echatzief</dc:creator>
    <dc:date>2023-08-22T10:37:17Z</dc:date>
    <item>
      <title>Reorder operations in setup</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12144185#M3105</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hi, hope you're doing great!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am creating a setup via the api, which contains multiple (x) operations. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I am aware of the fact that I can assign operations to my setup in a different way, thus changing the order of the final operations to the setup, but apparently that is not the desired way to achieve my goal.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'd appreciate if anyone can inform me about the possibility of changing the order of the operations to my setup after them being assigned to it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you in advance!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 13:54:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12144185#M3105</guid>
      <dc:creator>echatzief</dc:creator>
      <dc:date>2023-08-02T13:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder operations in setup</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12187831#M3106</link>
      <description>&lt;P&gt;Is there a chance it may not be possible?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:37:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12187831#M3106</guid>
      <dc:creator>echatzief</dc:creator>
      <dc:date>2023-08-22T10:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder operations in setup</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12195132#M3107</link>
      <description>&lt;P&gt;It's not currently possible, but with all of the work that's been going on with the CAM API, I hope it's coming soon.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 21:43:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12195132#M3107</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2023-08-24T21:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder operations in setup</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12195522#M3108</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13163818"&gt;@echatzief&lt;/a&gt;&amp;nbsp;-San.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if this is very limited and useful due to lack of functionality, but I have created a sample using a template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the attached f3d file, the operations are created in the order of the red marks with the largest tool diameter, but when the script is executed, the order is changed to the green ones.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 876px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1257929i4B3E2DC63CF9B2B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.cam as cam
import pathlib

THIS_DIR = pathlib.Path(__file__).resolve().parent

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        camObj: cam.CAM = get_cam_product()

        sorted_by_diameter(camObj.setups[0])

        camObj.generateAllToolpaths(True)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def sorted_by_diameter(setup: cam.Setup) -&amp;gt; None:
    if setup.operations.count &amp;lt; 2: return

    # create dict
    opeLst = []
    ope: cam.Operation = None
    for ope in setup.operations:
        tool: cam.Tool = ope.tool
        dia = tool.parameters.itemByName(
            "tool_diameter"
            ).value.value
        
        opeLst.append(
            {
                "dia": dia,
                "ope": ope
            }
        )

    # sort
    sortedOpeLst = sorted(opeLst, key = lambda x:x["dia"])

    # export template
    template = cam.CAMTemplate.createFromOperations(
        [d["ope"] for d in sortedOpeLst]
    )

    # import template
    cloneOpes = setup.createFromCAMTemplate(template)

    # set parameter
    clone: cam.Operation 
    for clone, sortedDict in zip(cloneOpes, sortedOpeLst):
        originalOpe: cam.Operation = sortedDict["ope"]
        originalPrm: cam.CAMParameter = originalOpe.parameters.itemByName('holeFaces')

        clonePrm: cam.CAMParameter = clone.parameters.itemByName('holeFaces')

        clonePrm.value.value = originalPrm.value.value

        # remove original operation
        originalOpe.deleteMe()


def get_cam_product() -&amp;gt; cam.CAM:
    app: core.Application = core.Application.get()
    activete_cam_env()

    return app.activeProduct


def activete_cam_env() -&amp;gt; None:
    app: core.Application = core.Application.get()
    ui: core.UserInterface = app.userInterface

    camWS: core.Workspace = ui.workspaces.itemById('CAMEnvironment') 
    camWS.activate()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, the operations are created in the template and the original ones are deleted, not reordered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't checked exactly, but there are some things that are not recorded when the template is created.&lt;BR /&gt;In the attached file, I have set HoleFaces in the geomatry tab for Drill only.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 270px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1257930iA1AD7C8FA19C02DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The parameters are different for each type of operation, so you may need to change the process for each type.&lt;BR /&gt;Also, if you are using CAD elements in the Heights tab, you may need to set them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2023 01:55:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12195522#M3108</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2023-08-25T01:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder operations in setup</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12199857#M3109</link>
      <description>&lt;P&gt;Currently it is not possible to change the Order of operations after it has been created. But which is something the team is aware of and working on it.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2023 17:19:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/reorder-operations-in-setup/m-p/12199857#M3109</guid>
      <dc:creator>boopathi.sivakumar</dc:creator>
      <dc:date>2023-08-27T17:19:09Z</dc:date>
    </item>
  </channel>
</rss>

