 #target aftereffects-8.0
 
 // for each layer that contains selected properties convert the value of the property at each
 // frame time to an event cue point
 
 function ConvertSelectedPropertiesToMarkers()
 {
 	function ConvertPropertyToMarkers(markerStream, prop)
 	{
 		// only do leaf streams
		if(! (prop instanceof Property)) {
			return;
		}
 		function GenerateIDPathForProp( prop ) {
 			return prop.parentProperty.name + "_" + prop.name;
 		}

 		function PrintPropToParmsAtTime( parms, prop, time )
 		{
	 			parms[GenerateIDPathForProp(prop)] = prop.valueAtTime(time, false); 		
 		}
 		
 		function SampleAtTime(markerStream, prop, time)
 		{
	 			var existingMarker = markerStream.valueAtTime(time, false);
	 			var curParms = existingMarker.getParameters();
				PrintPropToParmsAtTime(curParms, prop, time);
				existingMarker.setParameters(curParms);
	 			markerStream.setValueAtTime(time, existingMarker); 		
 		}
 		// sample the whole stream
		var owningLayer = prop;
		for(var depth = prop.propertyDepth; depth > 0; --depth) {
			owningLayer = owningLayer.parentProperty;
		}
 		if( prop.expressionEnabled ) {
 			var curTime = owningLayer.inPoint;
 			var outTime = owningLayer.outPoint;
 			for( ; curTime <= outTime; curTime += owningLayer.containingComp.frameDuration){
	 			SampleAtTime(markerStream, prop, curTime); 			
 			}
 		} else {
 		// just between the first and last keyframes
 			if(prop.numKeys) {
	 			for(var i = 1; i <= prop.numKeys; ++i) {
	 				var keyTime = prop.keyTime(i);
	 				SampleAtTime(markerStream, prop, keyTime);
	 			}
	 		} else {
	 			var existingMarker = markerStream.value;
	 			var curParms = existingMarker.getParameters();

				PrintPropToParmsAtTime(curParms, prop, owningLayer.startTime);
				existingMarker.setParameters(curParms);
	 			markerStream.setValueAtTime(owningLayer.startTime, existingMarker);
	 		}
 		}
 	}
	 if(app.project && app.project.activeItem && app.project.activeItem instanceof CompItem) {
 		var layerColl = app.project.activeItem.layers;
 		for(var i = 1; i <= layerColl.length; ++i) {
 			var curLayer = layerColl[i];
 			if(curLayer.selectedProperties && curLayer.selectedProperties.length > 0) {
 				var selProps = curLayer.selectedProperties;
 				for(var propIdx = 0; propIdx < selProps.length; ++propIdx ) {
 					ConvertPropertyToMarkers(curLayer.marker, selProps[propIdx]);
 				}
 			}
 		}
 	}
 }
 
 
 ConvertSelectedPropertiesToMarkers();