Copy link to clipboard
Copied
Hello, I have a question, I need a script to put a Name label that in this case would be numbers in a Keyframe. Number ranging from 1 to 205. Basically it would be a jsfl script. It would see which keyframes on the timeline I'm selecting and when I run it it would put the property; label Name > 1 > 2 > 3 and then it would go to each individual keyframe in sequence. I have a script but it not work yet., if necessary I can try to share it
I did not understand what exactly you need, but I sketched a small script that marks the keyframes
var dom = fl.getDocumentDOM()
var tl = dom.getTimeline()
var selectFrames = tl.getSelectedFrames();
for (var i = 0; i < selectFrames.length; i += 3) {
for (var a = selectFrames[(i + 1)]; a < selectFrames[(i + 2)]; a++) {
var objectFrames = tl.layers[selectFrames[(i)]].frames[a]
if (objectFrames.startFrame == a) {
objectFrames.name = a + 1;
}
}
}
Let's start small, if anything, I'll
...Copy link to clipboard
Copied
using name labels that look like numbers (even though they are strings and this can be done) is unwise.
and it's not clear to me what problem you're having. are you selecting only keyframes? do you need a script to find keyframes? something else?
Copy link to clipboard
Copied
Thanks for the answer. I've given a slightly better example below!
Copy link to clipboard
Copied
10 frames? looks like 205+ frames and there's no check to see if keyframes are selected.
Copy link to clipboard
Copied
Then. It was an example, the plan is for it to name the selected keyframes. there is a fixed example of 205, but the exemple is that can add a number label depending on the number of selected keyframes and name it 1, 2, 3... I don't mess with code, so I don't know how functional it is! it was just to have a base of what i'm trying to do
Copy link to clipboard
Copied
ok. then what problem do you see?
Copy link to clipboard
Copied
I select an amount of 205 empty keyframes to check. when running it returns the following error: fl.getTimelineSelect is not a function
Copy link to clipboard
Copied
I did not understand what exactly you need, but I sketched a small script that marks the keyframes
var dom = fl.getDocumentDOM()
var tl = dom.getTimeline()
var selectFrames = tl.getSelectedFrames();
for (var i = 0; i < selectFrames.length; i += 3) {
for (var a = selectFrames[(i + 1)]; a < selectFrames[(i + 2)]; a++) {
var objectFrames = tl.layers[selectFrames[(i)]].frames[a]
if (objectFrames.startFrame == a) {
objectFrames.name = a + 1;
}
}
}
Let's start small, if anything, I'll finalize it
Copy link to clipboard
Copied
thanks!! 😍. This works perfectly.
Copy link to clipboard
Copied
Super, this is what you need or need to somehow supplement the code?
Copy link to clipboard
Copied
It already works the way I need it!! Thanks
Copy link to clipboard
Copied
Could you please show your script
Copy link to clipboard
Copied
script to name selected keyframes with Number Labels. The plan is that it will add a value to each Keyframe selected in the property like this: if I have 10 keyframes selected in the timeline it will add Name/Labels going from 1 to 10. > in this example it is an anchor label.
The script I'm trying is like this:
Define a function that renames selected frames
function renameSelectedFrames() {
// Get current frame selection
var selection = fl.getTimelineSelect();
// Make sure a frame is selected
if (selection.length === 0) {
alert("Select some frames before running this script.");
fl.trace("No frame selected.");
return false;
}
// Check if the selection contains less than 205 frames
if (selection.length < 205) {
alert("Select at least 205 frames before running this script.");
fl.trace("Insufficient selection.");
return false;
}
// Rename each selected frame with a number from 1 to 205
for (var i = 0; i < selection.length; i++) {
var frame = selection[i];
var name = (i % 205) + 1; // get a number from 1 to 205
fl.setFrameName(frame, name.toString());
}
// Confirm that the operation completed successfully
alert("Frames have been successfully renamed.");
fl.trace("Frames have been successfully renamed.");
return true;
}
// Call function to rename selected frames
renameSelectedFrames();