Yo, mograph friends out there! Finally I launched my new series for sharing basic After Effects scripts today. Yep, I’ll share my crappy basic codes which are not fancy. Because I think it might be helpful for learning AE scripting. And even if it’s not helpful for other mographers, this series might help me out to learn coding more deeply. Yeah, my goal is always for myself!

So here’s the very first code for you. This one called “checkProp” is for checking property for scripting/expression. This is one of my oldest scripts I wrote for practice.

[Script Code]

var curComp = app.project.activeItem;
if(curComp != null && curComp instanceof CompItem){
    if(curComp.selectedProperties.length > 0){
        var result = new Array();
        var target = curComp.selectedProperties[0];
        result.push("Target: " + target.name + " (" + target.matchName + ")\r");
        getAllProps(target, "");
        for(var i = target.propertyDepth; i >= 1 ; i--){
            if(i == target.propertyDepth){
                result.push("\rpropertyGroup(" + i + "): " + target.propertyGroup(i).name + " (" + target.propertyGroup(i).matchName + ")");
            } else {
                result.push("propertyGroup(" + i + "): " + target.propertyGroup(i).name + " (" + target.propertyGroup(i).matchName + ")");
            }
        }
        alert(result.toString().replace(/,/g, "\r"), "Property Data");
        var confirmation = confirm("Do you want to export the data to .txt file?", false, "Export Option");
        if(confirmation){
            var myFile = File.saveDialog ("Save as", "Text: *.txt");
            if(myFile != null){
                myFile.open("w");
                myFile.write(result.toString().replace(/,/g, "\r"));
                myFile.close();
            }
        }
    } else {
        alert("Select a property in the timeline panel.");
    }
}



function getAllProps(theProp, indent){
    try{
        if(theProp.numProperties > 0){
            for(var i = 1; i <= theProp.numProperties; i++){ result.push(indent + "[" + i + "] " + theProp.property(i).name + " (" + theProp.property(i).matchName + ")"); if(theProp.property(i).numProperties > 0){
                    getAllProps(theProp.property(i), indent + "\t");
                }
            }
        }
    } catch(err){
        alert("Error at line # " + err.line.toString() + "\r" + err.toString());
    }
}

 

[Quick Explanation]
Copy the code & past them into Adobe ExtendScript Toolkit. And in AE, select a property you want to check, then running the script. So checkProp script will show you the property info like below. The info includes the property name & match name, child properties and parent properties.

If you have a great script called “ft-Toolbar2” from aescripts, it’s ultra easy to use this script. Create the new button as Javascript in the setting menu in ft-Toolbar2, and then copy & paste the code into the command field like below. So you can check property info with one click.

 

As you see, this series is not a sweet stuff. And it might not be friendly for beginners. Plus, I’m a crappy fake coder. So don’t expect too much for this series! But I’m sooo glad if a few mograph friends feel like this is useful for their great works.

Anyway, I would much appreciate it if you could give me a feedback. So please don’t hesitate to get in touch with me if you find some errors or better ways. And if you have any request for the series, hit me up on my Twitter. And if you don’t have time to read my crappy article, please follow & check my codes on my GitHub Gist. I hope I can update this series frequenly.

 

[Tiny Inside Story]
By the way, the reason why I start this series on my blog is that clever & awesome mographer, Adam Plouff enjoyed my checkProp script when I shared it with him on twitter. He is a really great developper and he made cool Rubber Hose script this year. Rubber Hose is a genuine game changer but I love his animation & design so much more than his tools. So it motivated me to start something about scripting. Thanks, Adam & sweet mograph community on twitter!

 

List of this series
checkProp
shapePathDirectionToggle
keyframeCorrect
invertStackOrder
layersTimeOffset

Advertisements