AE ENHANCERS

Expressions/Scripts/Presets
It is currently Mon May 20, 2013 1:37 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Add Marker
PostPosted: Thu Aug 12, 2004 11:04 am 
Offline

Joined: Wed Jul 07, 2004 2:30 pm
Posts: 319
Location: Charlotte, NC
I am a little tired and slow today so you will have to forgive me.

I need to add a marker to a layer and cannot figure the process out. The manual has an example, but I cannot get it to work. This is what the docs say:

To set a marker that says “Fade Up” at the 2 second mark:
var myMarker = new Marker("Fade Up");
myLayer.property("Marker").setValueAtTime(2, myMarker);

I've tried adding a layer item to attach the property to like:
var myLayer = app.project.item(1).layer(1);
var myMarker = new myLayer.property.Marker("Fade Up");

I keep getting the error that the property does not have a constructor.


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 11:46 am 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Did you take a look at Paul Tuersley's script "split layer at markers" in the scripts library? I think it works with markers in several ways, so you could probably learn something from taking a look at it.
Maybe Paul can elaborate?

Alex


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 12:31 pm 
Offline

Joined: Wed Jul 07, 2004 2:30 pm
Posts: 319
Location: Charlotte, NC
I did look at Paul's script, but he never creates a marker. I'm sure it's something simple and basic and I'm looking right past it. My scripting skills are still in the "hack" status.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 3:46 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 645
Location: London, UK
Took me a while to figure this out too, it should be:
var myMarker = new MarkerValue("Fade Up");
myLayer.Marker.setValueAtTime(2, myMarker);


Also, you can add blank markers using:
myLayer.Marker.addKey(2);

Paul T


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 5:08 am 
Offline

Joined: Wed Jul 07, 2004 2:30 pm
Posts: 319
Location: Charlotte, NC
Thanks Paul, the first snippet you gave worked. I couldn't get the blank marker to work though. I don't really need it, it doesn't hurt anything to name the markers.

This site is great, I hope we can get more people sharing ideas and scripts!

Take care.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 11:16 pm 
Offline
User avatar

Joined: Sat Jun 05, 2004 8:05 am
Posts: 137
Location: Los Angeles, CA
Here is an alternative syntax (probably a bit longer than Paul's)

The following script will set a new marker "Fade Up" at time 0:

// assume app.project.item(1) is CompItem, and has 1 layer.
var myMarker = new Marker("Fade Up");
app.project.item(1).layer(1).property("marker").setValueAtTime(0, myMarker);

If you'd like to set a new marker at current time, do this:

// assume app.project.item(1) is CompItem, and has 1 layer.
var myMarker = new Marker("Fade Up");
app.project.item(1).layer(1).property("marker").setValueAtTime(app.project.item(1).layer(1).time, myMarker);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 26, 2004 7:20 am 
Offline

Joined: Wed Jul 07, 2004 2:30 pm
Posts: 319
Location: Charlotte, NC
For some unknown reason, the empty marker script works now. I couldn't get it to work when I tried a while back. I gave it another shot today and it worked. Go figure.

After you make an empty marker, is there a way to go back and give it a name or change it's time value? I haven't delved into that much but I was just curious.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 15, 2004 1:54 pm 
Offline

Joined: Sat Jun 05, 2004 7:59 am
Posts: 645
Location: London, UK
Here's some good stuff from Keiko on using markers:

There are 2 example in 1 script. example 1 will change value (comment) of markers.
You can change any other markerValue property with same manner.

example 2 will snap markers to nearest second to time. This is a bit tricky. If I call
setValueAtTime with the "nearest second", I actually create a new marker at new
times. So I store data first, remove original markers and re-set by using data I stored.
I thought markerKeyTime = 10 will set time to 10, but it does not work.

-keiko

Code:
{
   // assume you have app.project.item(1) is comp
   // and comp.layer(1) is layer with multiple markers.
      
   // get markers
         var markers = app.project.item(1).layer(1).property("marker");
   
   // example 1:
   // change existing markers
      
         var undoStr = "Change marker comments";
         
         app.beginUndoGroup(undoStr);

         for(var i = 1; i <= markers.numKeys; i++) {
            // get MarkerValue of each marker
            var markerVal = markers.keyValue(i);
            // set MarkerValue.comment
            markerVal.comment = i + " marker";
            // set marker with new MarkerValue
            markers.setValueAtKey(i, markerVal);
         }
         
         app.endUndoGroup();
         
   // example 2:
   // snap all markers to nearest second in time

         undoStr = "Change marker time";
         var newMarkers = new Array();
         var newTimes = new Array();
         
   
         app.beginUndoGroup(undoStr);

         for(var i = markers.numKeys; i >= 1; i--) {
            // get MarkerValue of each marker
            var markerVal = markers.keyValue(i);
            newMarkers[newMarkers.length] = markerVal;
            // set time to nearest second
            var markerKeyTime = markers.keyTime(i);
            var newMarkerTime = Math.round(markerKeyTime);
            newTimes[newTimes.length] = newMarkerTime;
            // remove original markers
            markers.removeKey(i);
         }

         // add new markers with new value.
         for(var i = 0; i < newMarkers.length; i++) {
            markers.setValueAtTime(newTimes[i], newMarkers[i]);   
         }
         
         app.endUndoGroup();

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group