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 amIs 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 pmLike 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 pmDan,
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 pmNathan Clark
May 27, 2009 at 5:59 amOkay 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 amJust 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 amHey 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 amFairly 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]); } } DanM. Frank Emanuel
June 15, 2009 at 4:30 amSo, 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 amStill 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
Log in to reply.