Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions convert a 3d layer’s orientation to rotation

  • convert a 3d layer’s orientation to rotation

  • Nathan Clark

    May 25, 2009 at 10:56 am

    Is there a method / script / easy way to convert a 3d layer’s orientation values to rotation values?
    I am working in a medium sized 3d project and would love to avoid doing it manually for the hundreds of layers I am working with.
    I searched through all the scripting channels I know of to no avail 🙁
    Any assistance with this would be greatly appreciated!

    Thanks cow

    -Nathan.

    On Point Cloud Nine

  • Dan Ebberts

    May 25, 2009 at 2:54 pm

    Like this?

    {
    var myLayer = app.project.activeItem.selectedLayers[0];
    var temp = myLayer.property(“orientation”).value;
    myLayer.property(“xRotation”).setValue(temp[0]);
    myLayer.property(“yRotation”).setValue(temp[1]);
    myLayer.property(“zRotation”).setValue(temp[2]);
    myLayer.property(“orientation”).setValue([0,0,0]);
    }

    Dan

  • Nathan Clark

    May 25, 2009 at 3:28 pm

    Dan,

    You are the man!!

    That’s twice you’ve saved me now,

    I owe you big time!

    Do you have a donations system through motionscript you could refer me to?

    I think all your hard work and support to the community deserves some repayment!

    By the way,

    Would it be WAY harder to include in the script a way to undo the entire operation rather than having to undo multiple times to get back where I started?

    Thanks so very much

    –Nathan

    On Point Cloud Nine

  • Nathan Clark

    May 25, 2009 at 4:19 pm

    Checked Scripting section of motionscript and worked it out…

    Thankyou so much!!

    hmm scripting looks fun!!

    I love the scripts that I have so much in fact that I customized the launch pad to accommodate them!

    On Point Cloud Nine

  • Nathan Clark

    May 27, 2009 at 5:59 am

    Okay so what if the layer has rotation and orientation values set, and i need to convert it to just rotation values…

    Need a script that looks at a 3d layers rotation and orientation values and bakes them into rotation values only.

    Perhaps to make it usefull to a broader range of applications there could be a choice between baking to Rotation or baking to Orientation.

    Anybodies help with this would be spectacular!

    On Point Cloud Nine

  • Dan Ebberts

    May 27, 2009 at 8:21 am

    Just off the top of my head, I think that’s going to be a lot more work. There’s probably a way to do that entireley within the script using rotation transforms, but it might be easier to create a new temporary 3D layer, apply an orientation expression to it that captures the world orientation of the target layer (see recent thread on that topic), harvest that orientation value, and convert that to rotation (as before), then delete the temporary layer. Something like that.

    Dan

  • Nathan Clark

    May 29, 2009 at 2:48 am

    Hey Dan
    Your workaround is great, thanks!

    It seems though, that the below script will only run on the topmost selected layer, not all of them, is there a tweak we could make so as to ensure the script applies to all selected layers?

    {
    var myLayer = app.project.activeItem.selectedLayers[0];
    var temp = myLayer.property("orientation").value;
    myLayer.property("xRotation").setValue(temp[0]);
    myLayer.property("yRotation").setValue(temp[1]);
    myLayer.property("zRotation").setValue(temp[2]);
    myLayer.property("orientation").setValue([0,0,0]);
    }

    Thanks heaps,

    Nathan

    On Point Cloud Nine

  • Dan Ebberts

    May 29, 2009 at 3:03 am

    Fairly easy:

    {
    var myLayer;
    var temp;
    for (var i = 0; i < app.project.activeItem.selectedLayers.length; i++){ myLayer = app.project.activeItem.selectedLayers[i]; var temp = myLayer.property("orientation").value; myLayer.property("xRotation").setValue(temp[0]); myLayer.property("yRotation").setValue(temp[1]); myLayer.property("zRotation").setValue(temp[2]); myLayer.property("orientation").setValue([0,0,0]); } } Dan

  • M. Frank Emanuel

    June 15, 2009 at 4:30 am

    So, I’ve been searching and searching for a script that will convert a camera or 3D layer’s orientation and rotation to just rotation (zeroing out the orientation. In skewed camera views this is definitely not just a simple addition or subtraction of x,y and z values. Does anyone have a script that can pull this off?

  • Nathan Clark

    June 15, 2009 at 10:20 am

    Still trying to find one / work one out (but i am very new to scripting)

    Dan’s method may not do all the work for you, but at least it works. It is a slow workaround when you have a LOT OF LAYERS though.

    Its nice to see at least one other person looking for the same script.

    Perhaps a scripting genius will consider tackling this one now??

    On Point Cloud Nine

Viewing 1 - 10 of 18 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy