Mike Park
Forum Replies Created
-
I have narrowed the problem down to the “else if” statement at the end of the LinkAll function.
-
Error as follows:
After Effects warning:Expected:’
Expression disabled.Error occurred at line 1.
Comp:’Comp 1′
Layer: 4 (‘Red Solid’)
Property: ‘Center’It generates this error for every property which is able to have an expression applied.
The expression generated is as follows for that particular property:
thisComp.layer(“Red Solid”)undefined(“Effects”)(“Circle”)(“ADBE Circle-0001”)If you take out the undefined, it works fine. I don’t know what is creating the undefined in the middle of the expression.
Thanks for the look.
-
Ok Dan,
I am almost there. But now, the function is throwing me an “undefined” in the middle of my expression. I am not sure what the problem is. Otherwise, it appears to work. Any thoughts? Thanks again for the help.
{
// create an undo group
app.beginUndoGroup("Slave")
clearOutput();
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// add function to turn on all possible expressions and link to first layer;function LinkAll(parentProperty, propertyName)
{
if (parentProperty != null) //if parentProperty is something, then
{
for (var i = 1; i <= parentProperty.numProperties; i++) // increment for every property
{
var property = parentProperty.property(i); // put value of new property as value of old propertyif (property.propertyType == PropertyType.PROPERTY && property.canSetExpression) // test to see if property can be picwipped
{
try
{
if (property.enabled) // if the property is enabled
{
property.expression = "thisComp.layer" + "("" + mySel[s].name + "")" + propertyName + "("" + property.matchName + "")"; // set up expression to exact match of other layer
property.expressionEnabled = true; // enable expression
}
} catch (e) {} // catch everything else
}
else if ((property.propertyType == PropertyType.INDEXED_GROUP) || (property.propertyType == PropertyType.NAMED_GROUP))
LinkAll(property, propertyName + "("" + property.name + "")");
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// check to see that a layer is selected
var mySel = app.project.activeItem.selectedLayers;
if (mySel < 1){
alert("Please select one or more layers and try again.", "No Layers Selected");
}
else
// Display number of layers duplicated in info panel
write("Number of Layers duplicated = ");
writeLn(mySel.length);// duplicate layer(s) by increments
for (var s = 0; s < mySel.length; s++){
mySel[s].duplicate();
LinkAll (mySel[s]);
mySel[s].name = mySel[s].name + " Linked";
mySel[s].locked = true;}
// close the undo group
app.endUndoGroup();
} -
Alright Dan,
I have poured over this code and looked at the reference material, and still cant get this to work right. Sorry I have to bug you about this, but I dont know where to go from here. The code below (using your help above) successfully duplicates all selected layers. However, when the loop runs through the expression link section, it doesnt do anything. what am I missing? I really appreciate all the help. This will be quite the handy expression for duplicating a bunch of layers where you want all the attributes to track the changes in the other layers, especially for things like Particular.
{
// create an undo group
app.beginUndoGroup("Clone_and_link");var mySel = app.project.activeItem.selectedLayers;
// duplicate layer
for (var s = 0; s < mySel.length; s++){
mySel[s].duplicate();//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// add function to turn on all possible expressions and link to first layer;
function converterProcessExpressions(parentProperty, propertyName)
{
if (parentProperty != null) //if parentProperty is something, then
{
for (var i = 1; i <= parentProperty.numProperties; i++) // increment for every property
{
var property = parentProperty.property(i); // put value of new property as value of old propertyif (property.propertyType == PropertyType.PROPERTY && property.canSetExpression) // test to see if property can be picwipped
{
try
{
if (property.enabled) // if the property is enabled
{
property.expression = propertyName + "("" + property.matchName + "")"; // set up expression to exact match of other layer
property.expressionEnabled = true; // enable expression
}
} catch (e) {} // catch everything else
}
else if ((property.propertyType == PropertyType.INDEXED_GROUP) || (property.propertyType == PropertyType.NAMED_GROUP))
converterProcessExpressions(property, propertyName + "("" + property.name + "")");
}
}
}//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
}
// close the undo group
app.endUndoGroup();
} -
I agree that the same questions get asked a bunch in forums. A FAQ makes sense, but it is sometimes difficult for people to navigate and find answers to their question. Perhaps in addition to moving the question or topic, we could simply link the question to the appropriate answer in the FAQ section. That way the user could get the answer but it would only require someone to post a link instead of a full explaination. Just a thought.
-
Alright Dan, I am driving myself crazy with this. I can duplicate the layers in the comp, but only want to duplicate selected layers. I cannot figure out the proper syntax for this. Any help would be appreciated.
thanks,
Mike -
Dan,
Did they change the ability to use activeItem in CS5? It is throwing me an error everytime I try to use it to create a variable in the script.
var myComp = app.project.activeItem; -
thanks for responding, Dan.
Chris Keller wrote a script which kind of accomplishes this. In his script, he duplicates an enitre composition and offsets it for use with rb sterioscopic glasses. However the code I am interested in does what you are saying. It recursively goes through all properties of the layers and links them to the main comp. I want to port this so that I can simply do it to one layer. I have some programming knowledge from a long time ago in college (Fortran and C+) but am only starting to wade through Javascript. I will post the particular section from his free script in the box. Is this way more complicated than I am thinking?
Thanks,
Mike
// Recursively goes through all properties and links them to the main comp
function converterProcessExpressions(parentProperty, propertyName)
{
if (parentProperty != null)
{
for (var i = 1; i <= parentProperty.numProperties; ++i)
{
var property = parentProperty.property(i);if (property.propertyType == PropertyType.PROPERTY && property.canSetExpression)
{
try
{
if (property.enabled)
{
property.expression = propertyName + "("" + property.matchName + "")";
property.expressionEnabled = true;
}
} catch (e) {}
}
else if ((property.propertyType == PropertyType.INDEXED_GROUP) || (property.propertyType == PropertyType.NAMED_GROUP))
converterProcessExpressions(property, propertyName + "("" + property.name + "")");
}
}
}// -----------------------------------------------------------------------------------------------------------------------------
-
the easiest way is to make sure your animation loops in the precomp and then choose the random loop option under particular. Then the particles will all have a random start time within the precomp animation and give you that random feeling. If you want them to spin at different speeds, you can use several layers of particular and make several precomps with different rotation speeds and angles.
best,
mike
-
Jonas,
I am sorry to be the bearer of bad news, but what you are asking is not possible with Particular. You can precomp the 4 layers and animate the rotation in the precomp and use the precomp as a texture source for Particular, but Particular will not use a 3d precomp like you are trying. Maybe in future releases, but not with 2.0 and prior versions. This is really a truly 3d program type of effect.
Best,
Mike Park