toWorld scripting equivalent

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
axymark
Posts: 23
Joined: November 29th, 2013, 7:04 am

Hi,

Is there a scripting equivalent of toWorld expression? I need to find world position of (possibly) parented objects.

Thanks




edit: I realize i can set expression to temporary property and calculate it that way, but I dont want to do this.
shtep
Posts: 1
Joined: December 29th, 2014, 9:02 am
Location: Russia

Hello. I found boundingbox in world coordinates like this. Very strange method :roll:

Code: Select all

var slLayer = app.project.activeItem.selectedLayers[0];
wPoints=layerBoundingVertices(slLayer);
alert (wPoints[0][0]+" "+wPoints[0][1]+" "+wPoints[1][0]+" "+wPoints[1][1]);
function layerBoundingVertices(layer) {
   var boundingBox = layer.sourceRectAtTime(layer.inPoint, 1);
   var boundingVertices = [[boundingBox.left,boundingBox.top],[boundingBox.left,(boundingBox.top+boundingBox.height)],[(boundingBox.left+boundingBox.width),(boundingBox.top+boundingBox.height)],[(boundingBox.left+boundingBox.width),boundingBox.top]];
   var boudVertices = boundingVertices;
    layer.Effects.addProperty("Point Control");
    var NewBoundVertices = new Array();
    NewBoundVertices = [];
    layer("Effects")("Point Control")("Point").expression="thisLayer.toComp(["+boudVertices[0][0]+","+boudVertices[0][1]+"])";

    NewBoundVertices.push([layer("Effects")("Point Control")("Point").value[0],layer("Effects")("Point Control")("Point").value[1]]);

    layer("Effects")("Point Control")("Point").expression="thisLayer.toComp(["+boudVertices[1][0]+","+boudVertices[1][1]+"])";
    NewBoundVertices.push ([layer("Effects")("Point Control")("Point").value[0],layer("Effects")("Point Control")("Point").value[1]]);
    
    layer("Effects")("Point Control")("Point").expression="thisLayer.toComp(["+boudVertices[2][0]+","+boudVertices[2][1]+"])";
    NewBoundVertices.push ([layer("Effects")("Point Control")("Point").value[0],layer("Effects")("Point Control")("Point").value[1]]);
    
    layer("Effects")("Point Control")("Point").expression="thisLayer.toComp(["+boudVertices[3][0]+","+boudVertices[3][1]+"])";
    NewBoundVertices.push ([layer("Effects")("Point Control")("Point").value[0],layer("Effects")("Point Control")("Point").value[1]]);
    layer("Effects")("Point Control").remove();
    
   return NewBoundVertices;
}
stib
Posts: 21
Joined: December 10th, 2006, 10:23 pm
Contact:

I was looking for exactly the same thing. Did you find anything?
Post Reply