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!)
3D to 2D ScreenSpace .1b
Moderator: Paul Tuersley
-
- Posts: 18
- Joined: May 6th, 2012, 2:11 pm
Last edited by vidjuheffex on May 10th, 2012, 9:43 pm, edited 1 time in total.
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
You could either set up your onClicks this way:
or you could query the text in the button that called the function:
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
Code: Select all
myPanel.butLink.onClick = function() {
LinkOrBake(true);
};
//////////////
function LinkOrBake(link) {
if (link) {
Code: Select all
myPanel.butLink.onClick = LinkOrBake;
///////////////////////////
function LinkOrBake() {
if (this.text == "Link") {
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
-
- Posts: 18
- Joined: May 6th, 2012, 2:11 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.
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.
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
It should be:
else if (selectedLayers.threeDLayer == false){
else if (selectedLayers.threeDLayer == false){