Reset transform values, Remove effects of selected layers

What type of scripts do you need?

Moderator: byronnash

Post Reply
shivadas
Posts: 3
Joined: July 9th, 2015, 3:30 am

July 10th, 2015, 2:54 am

Dear all,

I'm looking for a script which will reset all values, and remove all effects, EXCEPT Time Remap, for all selected layers.
This is so I can export my slo-mo's out of After Effects and import them into the editing software, where I repast the transform/effects.

I would be crazily grateful!
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

July 22nd, 2015, 2:16 am

One problem is, scripts don't have access to properties default values, hence can't reset properties.

If you know which properties are concerned, and know their default values, a script doing this is possible though.

Xavier.
shivadas
Posts: 3
Joined: July 9th, 2015, 3:30 am

July 22nd, 2015, 2:23 am

Thanks for the reply. Would there be an option of 'removing' transform changes, and using the native properties of the source file? If this makes no sense at all, my apologies; I don't know much about scripts, and am just trying to setup a simpler workflow for my team.
Cheers!
beginUndoGroup
Posts: 81
Joined: November 27th, 2012, 6:41 am

July 22nd, 2015, 4:07 am

Hi again.

Here is a sample script that would, on all selected layers,
1- remove all effects;
2- reset all transform properties in the following way: remove expressions, remove keys, reset value to default.

I can't garanty that it covers all cases (there are many variants for cameras, lights, null layers, layers with parents, Shape and Text layers, etc...)
I only did a very quick test on a solid.
I don't know for lights, and don't have much time to dome some research.. (that part is skipped).

Please report if you find errors/missbehaviours.

Xavier.

Code: Select all

function reset(p, def){
	if (p.isModified){
		if (p.expression!=="") p.expression = "";
		while (p.numKeys>0) p.removeKey(1);
		p.setValue(def);
		};
	return;
	};
	
var comp = app.project.activeItem;
var n, N, L, D3, NULL, CAM, LIGHT, def;
if (comp instanceof CompItem && comp.selectedLayers.length>0){
	
	N = comp.selectedLayers.length;
	for (n=0; n<N; n++){
		L = comp.selectedLayers[n];
		NULL = L.nullLayer;
		CAM = L instanceof CameraLayer;
		LIGHT = L instanceof LightLayer;
		D3 = L.threeDLayer || LIGHT || CAM;
		
		// remove effects:
		while (L.effect.numProperties>0) L.effect.property(1).remove();
		
		// reset transform properties
		if (LIGHT){
			
			// don't know how to reset lights
			
			}
		else{

			// scale
			if (!CAM) reset(L.transform.scale, [100,100,100]);
			
			// position : THE DEFAULT LOCATION FOR LIGHTS AND CAMERAS IS DIFFERENT (value depend on cam settings)
			def = L.parent ? [0,0,0] : [comp.width/2,comp.height/2, 0];
			if (CAM) def[2] -= L.cameraOption.zoom;
			if (L.transform.position.dimensionsSeparated){
				reset(L.transform.xPosition, def[0]);
				reset(L.transform.yPosition, def[1]);
				if (D3) reset(L.transform.zPosition, def[2]);
				}
			else{
				reset(L.transform.position, def);
				};
			
			// anchor point
			def = L.source && !NULL ? [L.width/2, L.height/2, 0] : [0,0,0];
			if (!CAM) reset(L.transform.anchorPoint, def);
			else if (L.transform.pointOfInterest.canSetExpression) reset(L.transform.pointOfInterest, def);	// can be hidden for 1 node cameras
			
			// rotation
			if (D3){
				reset(L.transform.xRotation, 0);
				reset(L.transform.yRotation, 0);
				reset(L.transform.zRotation, 0);
				}
			else{
				reset(L.transform.rotation, 0);
				};
			
			// orientation
			if (D3){
				reset(L.transform.orientation, [0,0,0]);
				};
			};
		};
	}
else{
	alert("Please select some layers to reset");
	};
shivadas
Posts: 3
Joined: July 9th, 2015, 3:30 am

July 25th, 2015, 5:14 pm

It seems to be working! You're a godsend. Thanks!!
Post Reply