Benoit Kergosien
Forum Replies Created
-
Hi,
Sorry to dig but would it be possible with a pingpong loop?
Thanks,
Benoît.
-
Benoit Kergosien
June 15, 2017 at 11:02 am in reply to: Lock 2D position of a 3D layer with a customizable ZFor now I can only achieve to parent my 3d layer to a 2D null with the expression:
ref = thisComp.layer(“2D null”);
newPosition=ref.toComp([0,0,0]);Unfortunately I don’t know what to do next, and if its a good first step btw.
Benoît.
-
Hi,
Unfortunately I’ve got another problem :
the path copied via my script isn’t as accurate than the one copied manually.
See the image attached!
my code:
==============================================
var myComp=app.project.activeItem;
var myLayer=myComp.selectedLayers[0];
var myMask=myLayer.mask(1);
var times=new Array();// Creation of Effects
var mynumEffects=myLayer.property(“Effects”).numProperties;
myLayer.property(“Effects”).addProperty(“Point Control”);// Customisation of Effects
var Target=myLayer.property(“Effects”).property(mynumEffects+1);
Target.name=”myTarget”;
var myTarget=Target.property(“Point”);
mynumEffects+=1;// Read path content
var shape=myMask.maskPath.value,
verts=shape.vertices,
inTan=shape.inTangents,
outTan=shape.outTangents,
numVerts=verts.length;// In case of closed shape
if (shape.closed) {verts.push(verts[0]); inTan.push(inTan[0]); outTan.push(outTan[0]); numVerts++;};/*
// Inject 2D tangents into 3D property (tangents for a motion path always 3D, even for 2D)
for (var k=0; k < numVerts; k++) inTan [k][2] = outTan[k][2] = 0;
*/// Interval of time within wich the animation is adapted
var step = 2/(numVerts-1);
for (k=0; k -
Found!
var N=myLayer.property(“Effects”).numProperties; and not var N=myLayer.numProperties;
Benoit
-
I tried to accomplish that you explain to me yesterday but I’ve got error on the line:
var Target=myLayer.property(“Effects”).property(mynumEffects+1);
“After Effect error; Unable to call “property” because of parameter 1. Value 12 out of range 1 to 3.”
==========
var myComp=app.project.activeItem;
var myLayer=myComp.selectedLayers[0];
var myMask=myLayer.mask(1);
var times=new Array();// Creation of Effects
var mynumEffects=myLayer.numProperties;
myLayer.property(“Effects”).addProperty(“Point Control”);
myLayer.property(“Effects”).addProperty(“Slider Control”);
myLayer.property(“Effects”).addProperty(“Slider Control”);// Customisation of Effects
var Target=myLayer.property(“Effects”).property(mynumEffects+1);
Target.name=”myTarget”;
var myTarget=Target.property(“Point”);var slider01=myLayer.property(“Effects”).property(mynumEffects+2);
slider01.name=”mySlider01″;
var mySlider01=slider01.property(“Slider”);var slider02=myLayer.property(“Effects”).property(mynumEffects+3);
slider02.name=”mySlider02″;
var mySlider02=slider02.property(“Slider”);mynumEffects+=3;
// Read path content
var shape=myMask.maskPath.value,
verts=shape.vertices,
inTan=shape.inTangents,
outTan=shape.outTangents,
numVerts=verts.length;// In case of closed shape
if (shape.closed) {verts.push(verts[0]); inTan.push(inTan[0]); outTan.push(outTan[0]); numVerts++;};// Inject 2D tangents into 3D property (tangents for a motion path always 3D, even for 2D)
//for (var k=0; k < numVerts; k++) inTan [k][2] = outTan[k][2] = 0;// Interval of time within wich the animation is adapted
var step = 2/(numVerts-1);
for (k=0; k -
Thanks for those explanations Xavier, you are very helpful!
Benoit
-
Hi Xavier,
First of all, big thanks for your time.
I didn’t have time to test your last piece of code ’cause I’m stucked with the creation of Expression Controls on my layer.When I create only one of those (Target) the code works properly but when I add another one (mySlider) the code breaks.
=======================
var myComp=app.project.activeItem;
var myLayer=myComp.selectedLayers[0];
var myMask=myLayer.mask(1);
var Target=myLayer.property(“Effects”).addProperty(“Point Control”);
Target.name=”myTarget”;
var myTarget=myLayer.property(“Effects”).property(“myTarget”).property(“Point”);var mySlider=myLayer.property(“Effects”).addProperty(“Slider Control”);
mySlider.name=”mySlider”;var times=new Array();
var shape=myMask.maskPath.value,
verts=shape.vertices,
inTan=shape.inTangents,
outTan=shape.outTangents,
numVerts=verts.length;var step = 2/(numVerts-1);
for (k=0; k -
Oh… Apologies Xavier.
I really have to comment the code since the begining of my tests.
BTW is there a way to test if the var myTarget is 2D or 3D? To skip the injection of 2D tangents into 3D if my Target is a true 2D property with an if/else statement.
Thanks.
Benoit
-
Hi Xavier,
thanks for your quick answer, it worked like a charm.
Now I try to copy the motion path to a point control instead of the position property and I have got this error :
“After Effects error: Unable to call “setSpatialTangentsAtKey” because of parameter 2. Value array does not have 2 elements.”
=============================
var myComp=app.project.activeItem;
var myLayer=myComp.selectedLayers[0];
var myMask=myLayer.mask(1);
var myTarget=myLayer.property(“Effects”).property(“Point Control”).property(“Point”);
var times=new Array();var shape=myMask.maskPath.value,
verts=shape.vertices,
inTan=shape.inTangents,
outTan=shape.outTangents,
numVerts=verts.length;var step = 2/(numVerts-1);
for (k=0; k -
Hi Dan,
I did your corrections, thanks It works like it should.
I had this piece of code to the previous expression and I’m close to make it work.
The only problem is that the value returned since the last marker’s time is the marker’s index, how to avoid this?
Thanks again Dan, with all your help my abilities in expressions has already improved.
Benoit
m = marker;
prev = 0;
next = 0;
var arrayMarker=[];
var valueMarker=[];
markerComment="";
if (m.numKeys > 1){
nearest = m.nearestKey(time);
for (i=1; i<=m.numKeys; i++){
arrayMarker.push(m.key(i).comment);
}
for (i = 0; i < arrayMarker.length; i++) {
if (arrayMarker[i] == '') {
valueMarker.push(0);
}
else if (arrayMarker[i] == 'RIO') {
valueMarker.push(20);
}
else if (arrayMarker[i] == 'TOKYO') {
valueMarker.push(50);
}
}
if (nearest.time <= time){
prev = nearest.index;
if (prev < m.numKeys){
next = prev+1;
}
}else{
next = nearest.index;
}
if (next > 1){
prev = next-1;
}
if (prev != 0 && next != 0){
t1= m.key(prev).index;
t2=m.key(next).index;
markerComment=m.key(t1).comment;
if (markerComment==arrayMarker[t1-1]) {
Math.floor(linear(time,m.key(t1).time,m.key(t2).time,valueMarker[t1-1],valueMarker[t2-1]));
}else{
null // only have 1 marker -- add some code to deal with that
}
}
}else{ // no markers
0;
}
