我有一個插件可以檢測對象的像素寬度或高度是否更大。 它適用於其他物體,但對於形狀圖層,它只是表示構圖大小。 我的代碼是ExtendScript中的形狀圖層高度=構圖高度
pixelWidth = +currentLayer.width * +width/100;
pixelHeight = +currentLayer.height * +height/100;
變量寬度和高度的規模屬性,我讓它適用Scale屬性的百分比影響手術效果,所以其出現的規模。
感謝
我有一個插件可以檢測對象的像素寬度或高度是否更大。 它適用於其他物體,但對於形狀圖層,它只是表示構圖大小。 我的代碼是ExtendScript中的形狀圖層高度=構圖高度
pixelWidth = +currentLayer.width * +width/100;
pixelHeight = +currentLayer.height * +height/100;
變量寬度和高度的規模屬性,我讓它適用Scale屬性的百分比影響手術效果,所以其出現的規模。
感謝
嗯,我想你的問題是「如何獲得的形狀層的寬度和高度在After Effects?」。我對嗎?你爲什麼不這麼說。當你發現寬度和高度屬性只返回comp的寬度和高度。對於文本和形狀圖層,您需要使用sourceRectAtTime(timeT, extents)
方法。它會返回像這樣的對象{top, left, width, height}
這些是從圖層錨點測量的。
var layer = app.project.activeItem.selectedLayers[0];
$.writeln(layer.width); // gives the comp width
$.writeln(layer.height);// gives the comp height
// from the After Effects Scripting Guide
// AVLayer sourceRectAtTime() method
// app.project.item(index).layer(index).sourceRectAtTime(timeT, extents) Description
// Retrieves the rectangle bounds of the layer at the specified time index,
// corrected for text or shape layer content.
// Use, for example, to write text that is properly aligned to the baseline.
/**
* sourceRectAtTime
* @param {Number} The time index, in seconds. A floating-point value.
* @param {Boolean} True to include the extents, false otherwise. Extents apply to shape layers, increasing the size of the layer bounds as necessary.
*
* @return {Object} A JavaScript object with four attributes, {top, left, width, height}.
*/
var bounds = layer.sourceRectAtTime(0, true);
$.writeln(bounds.toSource());
非常感謝你:) –
Downvote,因爲這不是一個真正的問題。 – fabianmoronzirfas
爲什麼它不是一個問題?從語法上講,它可能有點不合適,但這是一個需要解決方案的編程問題,不是嗎? – stib