Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
vidjuheffex
Topic Author
Posts: 18
Joined: Sun May 06, 2012 2:11 pm

3D to 2D ScreenSpace .1b

Sun May 06, 2012 8:18 pm

Hello all,
Posting my first script out there. Works pretty simply, you select a 3d layer, then click one of the two buttons ('Link' or 'Bake') and the net result is an animated 2D null at the layers screen-space. More info and a download link at http://vidjuheffex.com/scripts/

That said, I would love for some people to look at the code. I have been learning JavaScript only for a few weeks now. For example right now I have Link and Bake executing two separate functions when bake is the same with the exception of one additional step. Not sure what the best way to pass a Boolean into a function would be (or if that is even the right approach). Also, I cobbled many parts of this from scripts as I was learning (THANK YOU ALL) and I noticed that none of the checks in the code seem to work, those that for example tell you to please have a comp active etc. Are these just way out of whack or am I missing something simple here. Anyway I look forward to updating this script and making many more.

UPDATE: version 0.2b is up, prompts work properly! All of them! (thanks Paul!)
Last edited by vidjuheffex on Thu May 10, 2012 9:43 pm, edited 1 time in total.
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: 3D to 2D ScreenSpace .1b

Wed May 09, 2012 4:24 am

You could either set up your onClicks this way:
myPanel.butLink.onClick = function() {
 LinkOrBake(true);
};
//////////////
function LinkOrBake(link) {
 if (link) {

or you could query the text in the button that called the function:
 myPanel.butLink.onClick = LinkOrBake;
///////////////////////////
function LinkOrBake() {
 if (this.text == "Link") {

Your alerts are possibly failing because you have a variable called scriptName that you haven't defined. BTW alerts only have titles on Windows.

If you turn on "Enable Javascript Debugger" in the General prefs you will get errors which should point you in the right direction, instead of it silently failing.

Paul
 
vidjuheffex
Topic Author
Posts: 18
Joined: Sun May 06, 2012 2:11 pm

Re: 3D to 2D ScreenSpace .1b

Thu May 10, 2012 7:57 pm

thanks! I'll have to give that a shot.
 
vidjuheffex
Topic Author
Posts: 18
Joined: Sun May 06, 2012 2:11 pm

Re: 3D to 2D ScreenSpace .1b

Thu May 10, 2012 8:27 pm

hey there, so I removed the scriptName portion and it worked, but then I wanted it to check for it's status as a 3d layer,

if ((activeItem == null) || !(activeItem instanceof CompItem)) {
alert("Please select a composition.");
} else {
var selectedLayers = activeItem.selectedLayers[0];
if (activeItem.selectedLayers.length == 0) {
alert("Please select a 3d layer in the active comp.");
}

else if (activeItem.selectedLayers.threeDLayer == false){
alert("Please select a 3d layer in the active comp.");
}

the .threeDLayer check is not working? Any hints? (it's followed by the else that executes the script.
 
Paul Tuersley
Posts: 704
Joined: Sat Jun 05, 2004 7:59 am
Location: London, UK

Re: 3D to 2D ScreenSpace .1b

Thu May 10, 2012 11:57 pm

It should be:

else if (selectedLayers.threeDLayer == false){
 
vidjuheffex
Topic Author
Posts: 18
Joined: Sun May 06, 2012 2:11 pm

Re: 3D to 2D ScreenSpace .1b

Sat May 12, 2012 1:03 pm

thanks!

Who is online

Users browsing this forum: No registered users and 2 guests