Skip to main content
ankz988
Participating Frequently
April 20, 2023
Answered

Jsfl script for Property of a keyframe

  • April 20, 2023
  • 2 replies
  • 1744 views

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


This topic has been closed for replies.
Correct answer Multoman

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


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

 

 

 

2 replies

Multoman
Inspiring
April 21, 2023

Could you please show your script

ankz988
ankz988Author
Participating Frequently
April 21, 2023

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();



 

kglad
Community Expert
Community Expert
April 20, 2023

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?

ankz988
ankz988Author
Participating Frequently
April 21, 2023

Thanks for the answer. I've given a slightly better example below!

kglad
Community Expert
Community Expert
April 21, 2023

10 frames?  looks like 205+ frames and there's no check to see if keyframes are selected.