Hi @echatzief -San.
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.
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.

# 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) -> None:
if setup.operations.count < 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() -> cam.CAM:
app: core.Application = core.Application.get()
activete_cam_env()
return app.activeProduct
def activete_cam_env() -> None:
app: core.Application = core.Application.get()
ui: core.UserInterface = app.userInterface
camWS: core.Workspace = ui.workspaces.itemById('CAMEnvironment')
camWS.activate()
In fact, the operations are created in the template and the original ones are deleted, not reordered.
I haven't checked exactly, but there are some things that are not recorded when the template is created.
In the attached file, I have set HoleFaces in the geomatry tab for Drill only.

The parameters are different for each type of operation, so you may need to change the process for each type.
Also, if you are using CAD elements in the Heights tab, you may need to set them.