Hi @brad.bylls .
Perhaps it is not possible to add elements to a timeline group.
Therefore, I deleted the timeline group and re-created it.
# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
def run(context):
ui = adsk.core.UserInterface.cast(None)
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
des: adsk.fusion.Design = app.activeProduct
root: adsk.fusion.Component = des.rootComponent
tlGroup: adsk.fusion.TimelineGroup = des.timeline.timelineGroups[-1]
targetFeat: adsk.fusion.MoveFeature = root.features.moveFeatures[-1]
add_group_like(tlGroup, targetFeat)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def add_group_like(
group: adsk.fusion.TimelineGroup,
targetFeat: adsk.fusion.MoveFeature) -> adsk.fusion.TimelineGroup:
# backup
backupCollapsed = group.isCollapsed
backupName = group.name
# get timeline group items
startObj: adsk.fusion.TimelineObject = group.item(0)
endObj: adsk.fusion.TimelineObject= group.item(group.count - 1)
# delete timeline group
group.isCollapsed = True
group.deleteMe(False)
# get the index that creates the group
indexes = [
startObj.index,
endObj.index,
targetFeat.timelineObject.index
]
startIdx = min(indexes)
endIdx = max(indexes)
# create new timeline group
des: adsk.fusion.Design = targetFeat.parentComponent.parentDesign
groups: adsk.fusion.TimelineGroups = des.timeline.timelineGroups
newGroup: adsk.fusion.TimelineGroup = groups.add(startIdx, endIdx)
# match state
newGroup.isCollapsed = backupCollapsed
newGroup.name = backupName
return newGroup
If you run it with the attached f3d file, you will see the following.
