1
$\begingroup$

Ok this is somethign very specific, and kinda dumb Many know they thing if going to the first key on the dope sheet and streteching/ extending / scaling all the frames to the desired lenght

BUT Is there any way to make it for the markers too? I used various camera angles using the markers(bind camera to marker), these are not affected by the scaling of the keyframes

Of course i could simply use time stretch , but this would affect the time the VBD volumes work

Or the only solution is moving them manually?

$\endgroup$

1 Answer 1

2
$\begingroup$

⚠️ This post is created with the help of an artificial intelligence.

This script is written by ChatGPT. Addon's were edited by me. I tested them and they work for me as intended, but I can't guaranty a quality (or a danger) of those scripts. I'm not experienced coder.


This script assumes that you want to scale the frame positions of all timeline markers in the current scene:

import bpy

def scale_markers(factor):
    # Get the current scene
    scene = bpy.context.scene

    # Check if there are any markers in the scene
    if scene.timeline_markers:
        # Loop through all markers in the scene
        for marker in scene.timeline_markers:
            # Scale marker's frame by the specified factor
            marker.frame = round(marker.frame * factor)

# Set the scaling factor (adjust as needed)
scaling_factor = 2.0

# Call the function to scale markers
scale_markers(scaling_factor)

Here's how to use the script:

  • Open Blender.
  • Switch to the "Scripting" workspace.
  • Create a new Text Editor and paste the script.
  • Adjust the scaling_factor variable to the desired scaling factor.
  • Run the script by pressing the "Run Script" button or using the "Alt + P" shortcut.

Addon - location Sidepanel ... copy paste into some text editor and save with .py extension. Install as usual.

bl_info = {
    "name": "Timeline Marker Scaler",
    "blender": (4, 00, 0),
    "category": "Animation",
    "author": "ChatGPT 3.5",
    "version": (5, 0, 0),
    "location": "Timeline > Sidepanel > Scale Markers",
    "description": "Stretch Markers on Timeline to sync position for stretched elements on timeline.",
}

import bpy

class SCENE_PT_scale_markers(bpy.types.Panel):
    bl_label = "Scale Markers"
    bl_idname = "SCENE_PT_scale_markers"
    bl_space_type = 'DOPESHEET_EDITOR'
    bl_region_type = 'UI'
    bl_category = 'Tools'

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(context.scene, "scaling_factor")
        row = layout.row()
        row.operator("scene.scale_markers", text="Scale Markers")

class SCENE_OT_scale_markers(bpy.types.Operator):
    bl_idname = "scene.scale_markers"
    bl_label = "Scale Markers"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self, context):
        # Get the current scene
        scene = context.scene

        factor = context.scene.scaling_factor

        # Check if there are any markers in the scene
        if context.scene.timeline_markers:
            # Loop through all markers in the scene
            for marker in context.scene.timeline_markers:
                # Scale marker's frame by the specified factor
                marker.frame = round(marker.frame * factor)
                
        return {'FINISHED'}

def register():
    bpy.utils.register_class(SCENE_PT_scale_markers)
    bpy.utils.register_class(SCENE_OT_scale_markers)
    bpy.types.Scene.scaling_factor = bpy.props.FloatProperty(name="Scaling Factor", default=2.0, min=0.1)

def unregister():
    bpy.utils.unregister_class(SCENE_PT_scale_markers)
    bpy.utils.unregister_class(SCENE_OT_scale_markers)
    del bpy.types.Scene.scaling_factor

if __name__ == "__main__":
    register()

enter image description here


Addon - location Menu ... or maybe better from editor's header menu > Marker > Scale Markers. Like that you can change value in Adjust Last Operation panel and see result realtime.

bl_info = {
    "name": "Dope Sheet Marker Scaler",
    "blender": (4, 00, 0),
    "category": "Animation",
    "author": "ChatGPT 3.5",
    "version": (2, 0, 0),
    "location": "Dope Sheet > Menu > Marker > Scale Markers",
    "description": "Stretch Markers on Timeline to sync position for stretched elements on timeline.",
}

import bpy

class OT_marker_scaler(bpy.types.Operator):
    bl_idname = "object.scale_markers"
    bl_label = "Scale Markers"
    bl_options = {'REGISTER', 'UNDO'}

    scaling_factor: bpy.props.FloatProperty(name="Scaling Factor", default=2.0, min=0.1)

    @classmethod
    def poll(cls, context):
        return context.scene.timeline_markers is not None

    def execute(self, context):
        scale_markers(context.scene, self.scaling_factor)
        return {'FINISHED'}

def scale_markers(scene, factor):
    # Check if there are any markers in the scene
    if scene.timeline_markers:
        # Loop through all markers in the scene
        for marker in scene.timeline_markers:
            # Scale marker's frame by the specified factor
            marker.frame = round(marker.frame * factor)

def menu_func(self, context):
    self.layout.operator(OT_marker_scaler.bl_idname)

def register():
    bpy.utils.register_class(OT_marker_scaler)
    bpy.types.DOPESHEET_MT_marker.append(menu_func)

def unregister():
    bpy.utils.unregister_class(OT_marker_scaler)
    bpy.types.DOPESHEET_MT_marker.remove(menu_func)

if __name__ == "__main__":
    register()

enter image description here

$\endgroup$
8
  • 1
    $\begingroup$ Seriously, it did it with no bug or adjustments? $\endgroup$
    – lemon
    Commented Jan 27 at 8:46
  • $\begingroup$ @lemon The first script - surprisingly, yes :) Addon versions - it was a few hours of errors :) I have zero knowledge, so it was hard for me to identify issue... it seems I was lucky, than anything else :) ... but now I know things like blender version has to be in bl_info specified :) $\endgroup$
    – vklidu
    Commented Jan 27 at 19:07
  • 1
    $\begingroup$ Hi vklidu as discussed with other moderators in a meta post we refrain from removing or downvoting any posts suspected to be AI generated content, but we agreed to mark and keep track of them in said posts. If you reviwed the code yourself and ensured it works, you may just omit the fact that it was generated with ChatGPT completely, and we may just overlook that fact and you can edit out the message from the post ;) $\endgroup$ Commented Jan 27 at 21:24
  • 1
    $\begingroup$ @duartefarrajotaramos OK ... Yes I tested if it works, I tried to check the code and structured explanation, but I'm not a coder to be sure the code is completely correct. So it seems to me right to inform followers how ai participated on this answer. And as described in related articles ... The warning link should direct you to some relevant page explaining more in details potentional risks of ai in general. $\endgroup$
    – vklidu
    Commented Jan 29 at 7:14
  • 1
    $\begingroup$ @MarkusvonBroady ... thanks for revision, round() make sense :) ... and about GPT - I wouldn't even know where to start, the first success encourage me to dive into it a bit, especially explanations of individual parts helped me, but yes when I saw my self in circle process of resending blender's errors to GPT I started to checking blender's templates to try found a fix (and no, it wasn't faster, but I ended up with something :) $\endgroup$
    – vklidu
    Commented Jan 29 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .