Move a Layer to a X/Y position via Script

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Christian1979
Posts: 5
Joined: July 26th, 2010, 10:55 am

Hi :-)

I need some help with my After Effects script :-)

I wanna add a command to my script to move a layer to a specific Postion (x360, y289)!

Here is my current Script (a part of it):

Code: Select all

   function Make_fields_view() {
	app.beginUndoGroup("Fields view");   
	if(myPanel.butRF.value == 1)
		{
			var reverse_fields_order =0;   // 0 or 1 for reverse field order
		}
	else
		{
			var reverse_fields_order =1;   // 0 or 1 for reverse field order
		}

	if ((app.project.activeItem == null) || ((app.project.activeItem != null) && !(app.project.activeItem instanceof CompItem)))
		{
			alert("Wählen Sie eine Komposition zum Erstellen der Halbbild-Vorschau!");	
		}
	else
		{
		var comp = app.project.activeItem;
		var myItemCollection = app.project.items; 
		var myComp_field_view = myItemCollection.addComp("Halbbild-Vorschau", comp.width, comp.height,comp.pixelAspect, comp.duration, comp.frameRate); // create comp interlaced or single field
		var comp_bg = myComp_field_view.layers.add(comp); //add original comp in fields view 
		var Fields_viewer_1 = myComp_field_view.layers.addSolid([.5,.5,.5], "2. Halbbild", comp.width,comp.height,comp.pixelAspect,comp.duration); // add solid in  fields view comp
		var comp_layer = myComp_field_view.layers.add(comp); //add original comp in fields view
I wanna move the layer "comp_bg" to the postion (x360, y289)

Code: Select all

var comp_bg = myComp_field_view.layers.add(comp); //add original comp in fields view 
Can someone help me? :-)
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

This should do it:

Code: Select all

comp_bg.property("ADBE Transform Group").property("ADBE Position").setValue([360,289]);
Christian1979
Posts: 5
Joined: July 26th, 2010, 10:55 am

Great! It works!!!
Thank you so much for your help! :-)
Post Reply