mirror of
https://github.com/jorgevasquezp/AFX_yTools.git
synced 2026-08-16 15:30:59 +00:00
Changed individual tools filenames, for better organization
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
function yToolBox(thisObj){␍ ␍ yToolBox_data = new Object();␍ yToolBox_data.icon = new File('../yScripts/yNet.png');␍ yToolBox_data.header = new File('../yScripts/header.png');␍ yToolBox_data.info = 'yorchnet.com';␍ yToolBox_data.name ='yToolBox';␍ yToolBox_data.ver ='0.4.2.1 alpha';␍ yToolBox_data.desc='Working tools so far...';␍ ␍ yToolBox_data.buttonWidth=126;␍ yToolBox_data.buttonHeight=30;␍ ␍ yToolBox_data.tools = [];␍␍ #include "../yScripts/y_JSExtensions.jsx";␍␍ //INCLUDED TOOLS␍ #include "../yScripts/y_setStructure.jsx";␍ #include "../yScripts/y_puppetRig.jsx";␍ #include "../yScripts/y_colorProbe.jsx";␍ #include "../yScripts/y_yBindBetween2.jsx";␍ #include "../yScripts/y_stopMotionLayer.jsx";␍ #include "../yScripts/y_CornerPin.jsx"; ␍ ␍␍ yToolBox_data.window = (thisObj instanceof Panel) ? thisObj : new Window("palette", yToolBox_data.info , undefined, {resizeable:true});␍␍␍ //MAIN WINDOW STRUCTURE.␍ var res_header ="group { orientation:'column', alignment:['fill','fill'],margins:[0,0,0,0] \␍ header: Group { orientation:'column', alignment:['center','top'],margins:[0,0,0,0]\␍ title: Image {icon:'"+yToolBox_data.header.path+'/'+yToolBox_data.header.name+"',preferredSize: [175, 35]},\␍ ver: StaticText { text:'"+yToolBox_data.ver+"', alignment:['center','center']}\␍ desc: StaticText { text:'"+yToolBox_data.desc+"', alignment:['center','center']}, \␍ }, \␍ main: Group { orientation:'column',alignment:['fill','fill'], alignChildren:['center','center'],"␍ var res = ""; //To be populated with the included Tools␍ var res_footer ="}, \␍ cmds: Group { alignment:['center','bottom'], \␍ icn_app: Image {icon:'"+ yToolBox_data.icon.path+'/'+ yToolBox_data.icon.name+"',preferredSize: [15, 18]},\␍ txt_info: StaticText { text:'"+yToolBox_data.info+"', alignment:['fill','center'] },\␍ }, \␍ }";␍␍ //POPULATE res with included tools.␍ for (i=0;i<yToolBox_data.tools.length;i++){␍ res = res + yToolBox_data.tools [i].btnLayout;␍ }␍␍ //LAYOUT Stuff␍ yToolBox_data.window.grp = yToolBox_data.window.add(res_header+res+res_footer);␍ yToolBox_data.window.layout.layout(true);␍ yToolBox_data.window.onResize = resize;␍ yToolBox_data.window.onClose = function () {delete yToolBox_data;};␍ ␍ //ASSIGN buttons to the activate function of each tool;␍ var toolBtns = yToolBox_data.window.grp.main.children;␍ for(n=0;n<toolBtns.length;n++){␍ toolBtns[n].onClick=yToolBox_data.tools[n].activate;␍ }␍ ␍ return yToolBox_data.window␍}␍␍function resize(){␍ this.layout.resize();␍ customize;␍ }␍␍function customize(){␍ g = yToolBox_data.window.grp.main.graphics;␍ ␍ myFont = ScriptUI.newFont('Cooper Std Black',ScriptUI.FontStyle.REGULAR ,14 ); ␍ myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [1, .45, 0, 1]); ␍ ␍ ␍ g.backgroundColor = myBrush;␍ /*g = yToolBox_data.window.grp.header.title.graphics;␍ g.font = myFont;␍␍ g =yToolBox_data.window.grp.header.graphics;␍ g.backgroundColor = myBrush;␍ */␍ ␍ }␍␍yToolBox(this);␍␍yToolBox_data.window.grp.onDraw = resize;␍yToolBox_data.window.grp.onDraw = customize;␍␍
|
||||||
@@ -1 +0,0 @@
|
|||||||
function yToolBox(thisObj){␍ ␍ yToolBox_data = new Object();␍ yToolBox_data.icon = new File('../yScripts/yNet.png');␍ yToolBox_data.header = new File('../yScripts/header.png');␍ yToolBox_data.info = 'yorchnet.com';␍ yToolBox_data.name ='yToolBox';␍ yToolBox_data.ver ='0.4.2.1 alpha';␍ yToolBox_data.desc='Working tools so far...';␍ ␍ yToolBox_data.buttonWidth=126;␍ yToolBox_data.buttonHeight=30;␍ ␍ yToolBox_data.tools = [];␍␍ #include "../yScripts/y_JSExtensions.jsx";␍␍ //INCLUDED TOOLS␍ #include "../yScripts/y_setStructure_0.1a.jsx";␍ #include "../yScripts/y_puppetRig_0.3.7a.jsx";␍ #include "../yScripts/y_colorProbe_0.2a.jsx";␍ #include "../yScripts/y_yBindBetween2_0.12b.jsx";␍ #include "../yScripts/y_stopMotionLayer_0.3a.jsx";␍ #include "../yScripts/y_CornerPin_0.11a.jsx"; ␍ ␍␍ yToolBox_data.window = (thisObj instanceof Panel) ? thisObj : new Window("palette", yToolBox_data.info , undefined, {resizeable:true});␍␍␍ //MAIN WINDOW STRUCTURE.␍ var res_header ="group { orientation:'column', alignment:['fill','fill'],margins:[0,0,0,0] \␍ header: Group { orientation:'column', alignment:['center','top'],margins:[0,0,0,0]\␍ title: Image {icon:'"+yToolBox_data.header.path+'/'+yToolBox_data.header.name+"',preferredSize: [175, 35]},\␍ ver: StaticText { text:'"+yToolBox_data.ver+"', alignment:['center','center']}\␍ desc: StaticText { text:'"+yToolBox_data.desc+"', alignment:['center','center']}, \␍ }, \␍ main: Group { orientation:'column',alignment:['fill','fill'], alignChildren:['center','center'],"␍ var res = ""; //To be populated with the included Tools␍ var res_footer ="}, \␍ cmds: Group { alignment:['center','bottom'], \␍ icn_app: Image {icon:'"+ yToolBox_data.icon.path+'/'+ yToolBox_data.icon.name+"',preferredSize: [15, 18]},\␍ txt_info: StaticText { text:'"+yToolBox_data.info+"', alignment:['fill','center'] },\␍ }, \␍ }";␍␍ //POPULATE res with included tools.␍ for (i=0;i<yToolBox_data.tools.length;i++){␍ res = res + yToolBox_data.tools [i].btnLayout;␍ }␍␍ //LAYOUT Stuff␍ yToolBox_data.window.grp = yToolBox_data.window.add(res_header+res+res_footer);␍ yToolBox_data.window.layout.layout(true);␍ yToolBox_data.window.onResize = resize;␍ yToolBox_data.window.onClose = function () {delete yToolBox_data;};␍ ␍ //ASSIGN buttons to the activate function of each tool;␍ var toolBtns = yToolBox_data.window.grp.main.children;␍ for(n=0;n<toolBtns.length;n++){␍ toolBtns[n].onClick=yToolBox_data.tools[n].activate;␍ }␍ ␍ return yToolBox_data.window␍}␍␍function resize(){␍ this.layout.resize();␍ customize;␍ }␍␍function customize(){␍ g = yToolBox_data.window.grp.main.graphics;␍ ␍ myFont = ScriptUI.newFont('Cooper Std Black',ScriptUI.FontStyle.REGULAR ,14 ); ␍ myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [1, .45, 0, 1]); ␍ ␍ ␍ g.backgroundColor = myBrush;␍ /*g = yToolBox_data.window.grp.header.title.graphics;␍ g.font = myFont;␍␍ g =yToolBox_data.window.grp.header.graphics;␍ g.backgroundColor = myBrush;␍ */␍ ␍ }␍␍yToolBox(this);␍␍yToolBox_data.window.grp.onDraw = resize;␍yToolBox_data.window.grp.onDraw = customize;␍␍
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
yOffsetCornerPin_data = new Object();
|
|
||||||
|
|
||||||
yOffsetCornerPin_data.scriptName = 'YCPOffset';
|
|
||||||
yOffsetCornerPin_data.scriptDesc = 'YToolBox Script for Offseting Corner Pin Effects';
|
|
||||||
yOffsetCornerPin_data.scriptVer = '0.1a';
|
|
||||||
yOffsetCornerPin_data.webLink = 'yorchnet.com';
|
|
||||||
yOffsetCornerPin_data.img = yToolBox_data.icon;
|
|
||||||
|
|
||||||
//if yToolBox Exists add it to its tool list.
|
|
||||||
if (typeof(yToolBox_data)!=='undefined'){
|
|
||||||
|
|
||||||
//it should be called from toolbox.
|
|
||||||
yOffsetCornerPin_data.buttonWidth=76;
|
|
||||||
yOffsetCornerPin_data.buttonHeight=30;
|
|
||||||
|
|
||||||
yOffsetCornerPin_data.btnLayout = "btn_"+yOffsetCornerPin_data.scriptName+": Button { preferredSize: ['"+ yOffsetCornerPin_data.buttonWidth+"','"+ yOffsetCornerPin_data.buttonHeight+"'], text:'"+yOffsetCornerPin_data.scriptName+"', helpTip:'"+yOffsetCornerPin_data.scriptDesc+"' }";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
yOffsetCornerPin_data.res = "window { \
|
|
||||||
type:'palette' , text:'"+yOffsetCornerPin_data.scriptName+' '+yOffsetCornerPin_data.scriptVer+"',\
|
|
||||||
\
|
|
||||||
\
|
|
||||||
info: Group { \
|
|
||||||
alignment:['center','bottom'], \
|
|
||||||
icon: Image {icon:'"+String(yOffsetCornerPin_data.img.path+"/"+yOffsetCornerPin_data.img.name)+"',preferredSize: [15, 18]},\
|
|
||||||
website: StaticText { text:'"+yOffsetCornerPin_data.webLink+"', alignment:['fill','center'] }\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
}";
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
// MAIN SCRIPT GOES HERE.
|
|
||||||
|
|
||||||
function getSelectedCornerPins() {
|
|
||||||
/* Function that returns a list of effect objects
|
|
||||||
that match any of the names
|
|
||||||
specified in validCornerPinNames. */
|
|
||||||
validCornerPinNames = ["ADBE Corner Pin","CC Power Pin"]
|
|
||||||
selectedLayers = app.project.activeItem.selectedLayers
|
|
||||||
cornerPins = []
|
|
||||||
for (layer=0;layer<selectedLayers.length;layer++){
|
|
||||||
myLayer = selectedLayers[layer];
|
|
||||||
myEffects = myLayer.property("ADBE Effect Parade");
|
|
||||||
for(effect=1;effect<=myEffects.numProperties;effect++){
|
|
||||||
for(validCornerPinName=0;validCornerPinName<validCornerPinNames.length;validCornerPinName++){
|
|
||||||
if ( myEffects.property(effect).matchName == validCornerPinNames[validCornerPinName] && myEffects.property(effect).selected == true){
|
|
||||||
cornerPins.push(myEffects.property(effect))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cornerPins
|
|
||||||
}
|
|
||||||
function getLayer(effect){
|
|
||||||
/* If given a layer's effect object
|
|
||||||
this function returns the layer object */
|
|
||||||
layer = effect.parentProperty.parentProperty
|
|
||||||
return layer
|
|
||||||
}
|
|
||||||
function addEffect(layer,effect_string,effect_name){
|
|
||||||
new_effect = layer.property("ADBE Effect Parade").addProperty(effect_string);
|
|
||||||
new_effect.name = effect_name;
|
|
||||||
return new_effect
|
|
||||||
}
|
|
||||||
function addPointControls(effect){
|
|
||||||
/*calling the getLayer(effect) is resetting my effect object to null, and not allowing me to do everything in a single sitting. I think it has to do with variable scopes.*/
|
|
||||||
local = {};
|
|
||||||
local.effect = effect;
|
|
||||||
base_name = local.effect.name;
|
|
||||||
names = ["Upper Left","Upper Right","Lower Left","Lower Right"];
|
|
||||||
|
|
||||||
for (i=1;i<=4;i++){
|
|
||||||
expression = 'try{\
|
|
||||||
effect("'+base_name+'")('+(i)+')+effect("'+base_name+'_'+names[i-1]+'_'+'Offset'+'")("Point")\
|
|
||||||
}catch(err){\
|
|
||||||
[0,0]\
|
|
||||||
}'
|
|
||||||
local.effect.property(i).expression = expression;
|
|
||||||
}
|
|
||||||
layer = getLayer(effect);
|
|
||||||
for(i=0;i<=3;i++){
|
|
||||||
new_effect = addEffect(layer,"Point Control",base_name+"_"+names[i]+"_"+"Offset");
|
|
||||||
new_effect.property("Point").setValue([0,0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function processCornerPins(){
|
|
||||||
pins = getSelectedCornerPins();
|
|
||||||
for(pin=0;pin<pins.length;pin++){
|
|
||||||
addPointControls(pins[pin])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
|
|
||||||
function build_yOffsetCornerPin_data_UI(){
|
|
||||||
yOffsetCornerPin_data.window = new Window ( yOffsetCornerPin_data.res);
|
|
||||||
yOffsetCornerPin_data.window.show();
|
|
||||||
}
|
|
||||||
yOffsetCornerPin_data.activate =processCornerPins ;
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
yEntreDeux_data = new Object();
|
|
||||||
|
|
||||||
yEntreDeux_data.scriptName = 'yBindBetween2';
|
|
||||||
yEntreDeux_data.scriptDesc = 'Constraints a layer between two others, position and rotation-wise';
|
|
||||||
|
|
||||||
yEntreDeux_data.scriptVer = '0.12a';
|
|
||||||
yEntreDeux_data.webLink = 'yorchnet.com';
|
|
||||||
|
|
||||||
//if yToolBox Exists add it to its tool list.
|
|
||||||
if (typeof(yToolBox_data)!=='undefined'){
|
|
||||||
yToolBox_data.tools.push(yEntreDeux_data);
|
|
||||||
|
|
||||||
//it should be called from toolbox.
|
|
||||||
/* yEntreDeux_data.buttonWidth=76;
|
|
||||||
yEntreDeux_data.buttonHeight=30;
|
|
||||||
*/
|
|
||||||
yEntreDeux_data.btnLayout = "btn_"+yEntreDeux_data.scriptName+": Button { preferredSize: ['"+yToolBox_data.buttonWidth+"','"+ yToolBox_data.buttonHeight+"'], text:'"+yEntreDeux_data.scriptName+"', helpTip:'"+yEntreDeux_data.scriptDesc+"' }";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
// MAIN SCRIPT GOES HERE.
|
|
||||||
|
|
||||||
function build_yEntreDeux_data_UI(){
|
|
||||||
//script info
|
|
||||||
yEntreDeux_data = new Object();
|
|
||||||
yEntreDeux_data.scriptName = 'yEntreDeux';
|
|
||||||
yEntreDeux_data.scriptVer = '0.1a';
|
|
||||||
yEntreDeux_data.webLink = 'yorchnet.com';
|
|
||||||
|
|
||||||
|
|
||||||
// GUI
|
|
||||||
yEntreDeux_data.res= "window { \
|
|
||||||
type:'palette' , text:'"+yEntreDeux_data.scriptName+' '+yEntreDeux_data.scriptVer+"',margins:[10,10,10,10],spacing:[5,5,5,5]\
|
|
||||||
\
|
|
||||||
lst_layer: DropDownList {title:'layer to constrain',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the layer you wish to constrain'}\
|
|
||||||
lst_pa: DropDownList {title:'parent a',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the first parent'}\
|
|
||||||
lst_pb: DropDownList {title:'parent b',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the second parent'}\
|
|
||||||
exec_btn: Button {text:'do It',preferredSize:[150,35],helpTip:'do it'}\
|
|
||||||
\
|
|
||||||
info: Group { \
|
|
||||||
alignment:['center','bottom'], \
|
|
||||||
icon: Image {preferredSize: [15, 18]},\
|
|
||||||
website: StaticText { text:'"+yEntreDeux_data.webLink+"', alignment:['fill','center'] },\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
}";
|
|
||||||
|
|
||||||
|
|
||||||
yEntreDeux_data.window = new Window (yEntreDeux_data.res);
|
|
||||||
//never got around of assigning the icon any other way, but it works.
|
|
||||||
yEntreDeux_data.window.info.icon.image = yToolBox_data.icon;
|
|
||||||
|
|
||||||
refresh(); // reloads the possible layers in the gui.
|
|
||||||
|
|
||||||
yEntreDeux_data.window.exec_btn.onClick = run;
|
|
||||||
|
|
||||||
|
|
||||||
yEntreDeux_data.window.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(){
|
|
||||||
app.beginUndoGroup('Bind Between Two');
|
|
||||||
|
|
||||||
selectedLayerName=String(yEntreDeux_data.window.lst_layer.selection);
|
|
||||||
parentALayerName=String(yEntreDeux_data.window.lst_pa.selection);
|
|
||||||
parentBLayerName=String(yEntreDeux_data.window.lst_pb.selection);
|
|
||||||
layerN = selectedLayerName.substr(0, selectedLayerName.indexOf('.'));
|
|
||||||
paN = parentALayerName.substr(0, parentALayerName.indexOf('.'));
|
|
||||||
pbN = parentBLayerName.substr(0, parentBLayerName.indexOf('.'));
|
|
||||||
layer = app.project.activeItem.layers[layerN];
|
|
||||||
pa = app.project.activeItem.layers[paN];
|
|
||||||
pb = app.project.activeItem.layers[pbN];
|
|
||||||
layer("Effects").addProperty("Layer Control");
|
|
||||||
layer("Effects")("Layer Control").name = 'ctrl01';
|
|
||||||
layer("Effects")("ctrl01")("Layer").setValue(pa.index);
|
|
||||||
layer("Effects").addProperty("Layer Control");
|
|
||||||
layer("Effects")("Layer Control").name = 'ctrl02';
|
|
||||||
layer("Effects")("ctrl02")("Layer").setValue(pb.index);
|
|
||||||
layer("Effects").addProperty("Angle Control");
|
|
||||||
layer("Effects")("Angle Control").name = 'offset';
|
|
||||||
layer("Effects")("offset")("Angle").setValue(90);
|
|
||||||
posExp ='a = effect("ctrl01")("Layer");\
|
|
||||||
b = effect("ctrl02")("Layer");\
|
|
||||||
aPos = a.toComp(a.anchorPoint);\
|
|
||||||
bPos = b.toComp(b.anchorPoint);\
|
|
||||||
(aPos+bPos)/2'
|
|
||||||
rotExp ='a =effect("ctrl01")("Layer");\
|
|
||||||
b = effect("ctrl02")("Layer");\
|
|
||||||
aPos = a.toComp(a.anchorPoint);\
|
|
||||||
bPos = b.toComp(b.anchorPoint);\
|
|
||||||
rx = lookAt(aPos,bPos)[0];\
|
|
||||||
ry = lookAt(aPos,bPos)[1];\
|
|
||||||
offset = effect("offset")("Angle");\
|
|
||||||
if (aPos[1] > bPos[1]){\
|
|
||||||
(ry) -90 + offset\
|
|
||||||
}else{\
|
|
||||||
90 - (ry) + offset\
|
|
||||||
}'
|
|
||||||
layer.transform.position.expression = posExp;
|
|
||||||
layer.transform.rotation.expression= rotExp;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
myNull = app.project.activeItem.layers.addNull();
|
|
||||||
myNull.transform.anchorPoint.setValue([50,50]);
|
|
||||||
myNull.name = yUniStr('colorProbe'); //Generates a Unique Name by adding numbers at the end of the main string.
|
|
||||||
layerCTRL = myNull("Effects").addProperty("Layer Control");
|
|
||||||
layerCTRL.name='sampledLayer';
|
|
||||||
colorCTRL = myNull("Effects").addProperty("Color Control");
|
|
||||||
colorCTRL.name='outColor';
|
|
||||||
radiusCTRL = myNull("Effects").addProperty("Slider Control");
|
|
||||||
radiusCTRL.name ='radius';
|
|
||||||
myNull("Effects")("radius")('Slider').setValue(0.5);
|
|
||||||
colExp = 'myLayer = thisLayer("Effects")("sampledLayer")("Layer");\
|
|
||||||
p = thisLayer.toWorld(thisLayer.transform.anchorPoint);\
|
|
||||||
r = thisLayer("Effects")("radius")("Slider");\
|
|
||||||
myLayer.sampleImage(p, radius = [r, r], postEffect=true, t=time)';
|
|
||||||
myNull("Effects")('outColor')('Color').expression=colExp;
|
|
||||||
*/
|
|
||||||
|
|
||||||
app.endUndoGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
function refresh(){
|
|
||||||
//alert('going');
|
|
||||||
lists=[yEntreDeux_data.window.lst_pa,yEntreDeux_data.window.lst_layer,yEntreDeux_data.window.lst_pb]//they should be in this order for the assignment of the selection index works right/
|
|
||||||
for(i=0;i<lists.length;i++){
|
|
||||||
lists[i].removeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
var sel = app.project.activeItem.selectedLayers;
|
|
||||||
var compLayers = app.project.activeItem.layers;
|
|
||||||
var selectableLayers = [];
|
|
||||||
for(i=1;i<=compLayers.length;i++){
|
|
||||||
selectableLayers.push(compLayers[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var lst_layer = yEntreDeux_data.window.lst_layer;
|
|
||||||
var lst_pa = yEntreDeux_data.window.lst_pa;
|
|
||||||
var lst_pb = yEntreDeux_data.window.lst_pb;
|
|
||||||
|
|
||||||
for(i=0;i<lists.length;i++){
|
|
||||||
for(j=0;j<selectableLayers.length;j++){
|
|
||||||
lists[i].add('item',selectableLayers[j].index+"."+selectableLayers[j].name);
|
|
||||||
/*for(i=0;i<lists.length;i++){
|
|
||||||
lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
}*/
|
|
||||||
//alert(selectableLayers[i].name)
|
|
||||||
}
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
}
|
|
||||||
//var selIndex = sel[0].index-1;
|
|
||||||
lst_layer.selection = 0;
|
|
||||||
lst_pa.selection = 0;
|
|
||||||
lst_pb.selection = 0;
|
|
||||||
}
|
|
||||||
//build_yEntreDeux_UI();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
/*
|
|
||||||
function build_yEntreDeux_data_UI(){
|
|
||||||
yEntreDeux_data.window = new Window (yEntreDeux_data.res);
|
|
||||||
yEntreDeux_data.window.show();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
yEntreDeux_data.activate = build_yEntreDeux_data_UI ;
|
|
||||||
|
|
||||||
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
|
|
||||||
if (typeof(yToolBox_data)=='undefined'){
|
|
||||||
yEntreDeux_data.activate();
|
|
||||||
}else{
|
|
||||||
}
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
yEntreDeux_data = new Object();
|
|
||||||
|
|
||||||
yEntreDeux_data.scriptName = 'yBindBetween2';
|
|
||||||
yEntreDeux_data.scriptDesc = 'Constraints a layer between two others, position and rotation-wise';
|
|
||||||
|
|
||||||
yEntreDeux_data.scriptVer = '0.12a';
|
|
||||||
yEntreDeux_data.webLink = 'yorchnet.com';
|
|
||||||
|
|
||||||
//if yToolBox Exists add it to its tool list.
|
|
||||||
if (typeof(yToolBox_data)!=='undefined'){
|
|
||||||
yToolBox_data.tools.push(yEntreDeux_data);
|
|
||||||
|
|
||||||
//it should be called from toolbox.
|
|
||||||
/* yEntreDeux_data.buttonWidth=76;
|
|
||||||
yEntreDeux_data.buttonHeight=30;
|
|
||||||
*/
|
|
||||||
yEntreDeux_data.btnLayout = "btn_"+yEntreDeux_data.scriptName+": Button { preferredSize: ['"+yToolBox_data.buttonWidth+"','"+ yToolBox_data.buttonHeight+"'], text:'"+yEntreDeux_data.scriptName+"', helpTip:'"+yEntreDeux_data.scriptDesc+"' }";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
// MAIN SCRIPT GOES HERE.
|
|
||||||
|
|
||||||
function build_yEntreDeux_data_UI(){
|
|
||||||
//script info
|
|
||||||
yEntreDeux_data = new Object();
|
|
||||||
yEntreDeux_data.scriptName = 'yEntreDeux';
|
|
||||||
yEntreDeux_data.scriptVer = '0.1a';
|
|
||||||
yEntreDeux_data.webLink = 'yorchnet.com';
|
|
||||||
|
|
||||||
|
|
||||||
// GUI
|
|
||||||
yEntreDeux_data.res= "window { \
|
|
||||||
type:'palette' , text:'"+yEntreDeux_data.scriptName+' '+yEntreDeux_data.scriptVer+"',margins:[10,10,10,10],spacing:[5,5,5,5]\
|
|
||||||
\
|
|
||||||
lst_layer: DropDownList {title:'layer to constrain',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the layer you wish to constrain'}\
|
|
||||||
lst_pa: DropDownList {title:'parent a',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the first parent'}\
|
|
||||||
lst_pb: DropDownList {title:'parent b',preferredSize:[150,35],textSelection:'Escoge',helpTip:'Select the second parent'}\
|
|
||||||
exec_btn: Button {text:'do It',preferredSize:[150,35],helpTip:'do it'}\
|
|
||||||
\
|
|
||||||
info: Group { \
|
|
||||||
alignment:['center','bottom'], \
|
|
||||||
icon: Image {preferredSize: [15, 18]},\
|
|
||||||
website: StaticText { text:'"+yEntreDeux_data.webLink+"', alignment:['fill','center'] },\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
}";
|
|
||||||
|
|
||||||
|
|
||||||
yEntreDeux_data.window = new Window (yEntreDeux_data.res);
|
|
||||||
//never got around of assigning the icon any other way, but it works.
|
|
||||||
yEntreDeux_data.window.info.icon.image = yToolBox_data.icon;
|
|
||||||
|
|
||||||
refresh(); // reloads the possible layers in the gui.
|
|
||||||
|
|
||||||
yEntreDeux_data.window.exec_btn.onClick = run;
|
|
||||||
|
|
||||||
|
|
||||||
yEntreDeux_data.window.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(){
|
|
||||||
app.beginUndoGroup('Bind Between Two');
|
|
||||||
|
|
||||||
selectedLayerName=String(yEntreDeux_data.window.lst_layer.selection);
|
|
||||||
parentALayerName=String(yEntreDeux_data.window.lst_pa.selection);
|
|
||||||
parentBLayerName=String(yEntreDeux_data.window.lst_pb.selection);
|
|
||||||
layerN = selectedLayerName.substr(0, selectedLayerName.indexOf('.'));
|
|
||||||
paN = parentALayerName.substr(0, parentALayerName.indexOf('.'));
|
|
||||||
pbN = parentBLayerName.substr(0, parentBLayerName.indexOf('.'));
|
|
||||||
layer = app.project.activeItem.layers[layerN];
|
|
||||||
pa = app.project.activeItem.layers[paN];
|
|
||||||
pb = app.project.activeItem.layers[pbN];
|
|
||||||
layer("Effects").addProperty("Layer Control");
|
|
||||||
layer("Effects")("Layer Control").name = 'ctrl01';
|
|
||||||
layer("Effects")("ctrl01")("Layer").setValue(pa.index);
|
|
||||||
layer("Effects").addProperty("Layer Control");
|
|
||||||
layer("Effects")("Layer Control").name = 'ctrl02';
|
|
||||||
layer("Effects")("ctrl02")("Layer").setValue(pb.index);
|
|
||||||
layer("Effects").addProperty("Angle Control");
|
|
||||||
layer("Effects")("Angle Control").name = 'offset';
|
|
||||||
layer("Effects")("offset")("Angle").setValue(90);
|
|
||||||
layer("Effects").addProperty("Slider Control");
|
|
||||||
layer("Effects")("Slider Control").name = 'weight';
|
|
||||||
layer("Effects")("weight")(1).setValue(50);
|
|
||||||
posExp ='a = effect("ctrl01")("Layer");\
|
|
||||||
b = effect("ctrl02")("Layer");\
|
|
||||||
aPos = a.toComp(a.anchorPoint);\
|
|
||||||
bPos = b.toComp(b.anchorPoint);\
|
|
||||||
w= effect("weight")(1)/100;\
|
|
||||||
(aPos*(1-w)+bPos*(w))'
|
|
||||||
rotExp ='a =effect("ctrl01")("Layer");\
|
|
||||||
b = effect("ctrl02")("Layer");\
|
|
||||||
aPos = a.toComp(a.anchorPoint);\
|
|
||||||
bPos = b.toComp(b.anchorPoint);\
|
|
||||||
rx = lookAt(aPos,bPos)[0];\
|
|
||||||
ry = lookAt(aPos,bPos)[1];\
|
|
||||||
offset = effect("offset")("Angle");\
|
|
||||||
if (aPos[1] > bPos[1]){\
|
|
||||||
(ry) -90 + offset\
|
|
||||||
}else{\
|
|
||||||
90 - (ry) + offset\
|
|
||||||
}'
|
|
||||||
layer.transform.position.expression = posExp;
|
|
||||||
layer.transform.rotation.expression= rotExp;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
myNull = app.project.activeItem.layers.addNull();
|
|
||||||
myNull.transform.anchorPoint.setValue([50,50]);
|
|
||||||
myNull.name = yUniStr('colorProbe'); //Generates a Unique Name by adding numbers at the end of the main string.
|
|
||||||
layerCTRL = myNull("Effects").addProperty("Layer Control");
|
|
||||||
layerCTRL.name='sampledLayer';
|
|
||||||
colorCTRL = myNull("Effects").addProperty("Color Control");
|
|
||||||
colorCTRL.name='outColor';
|
|
||||||
radiusCTRL = myNull("Effects").addProperty("Slider Control");
|
|
||||||
radiusCTRL.name ='radius';
|
|
||||||
myNull("Effects")("radius")('Slider').setValue(0.5);
|
|
||||||
colExp = 'myLayer = thisLayer("Effects")("sampledLayer")("Layer");\
|
|
||||||
p = thisLayer.toWorld(thisLayer.transform.anchorPoint);\
|
|
||||||
r = thisLayer("Effects")("radius")("Slider");\
|
|
||||||
myLayer.sampleImage(p, radius = [r, r], postEffect=true, t=time)';
|
|
||||||
myNull("Effects")('outColor')('Color').expression=colExp;
|
|
||||||
*/
|
|
||||||
|
|
||||||
app.endUndoGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
function refresh(){
|
|
||||||
//alert('going');
|
|
||||||
lists=[yEntreDeux_data.window.lst_pa,yEntreDeux_data.window.lst_layer,yEntreDeux_data.window.lst_pb]//they should be in this order for the assignment of the selection index works right/
|
|
||||||
for(i=0;i<lists.length;i++){
|
|
||||||
lists[i].removeAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
var sel = app.project.activeItem.selectedLayers;
|
|
||||||
var compLayers = app.project.activeItem.layers;
|
|
||||||
var selectableLayers = [];
|
|
||||||
for(i=1;i<=compLayers.length;i++){
|
|
||||||
selectableLayers.push(compLayers[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var lst_layer = yEntreDeux_data.window.lst_layer;
|
|
||||||
var lst_pa = yEntreDeux_data.window.lst_pa;
|
|
||||||
var lst_pb = yEntreDeux_data.window.lst_pb;
|
|
||||||
|
|
||||||
for(i=0;i<lists.length;i++){
|
|
||||||
for(j=0;j<selectableLayers.length;j++){
|
|
||||||
lists[i].add('item',selectableLayers[j].index+"."+selectableLayers[j].name);
|
|
||||||
/*for(i=0;i<lists.length;i++){
|
|
||||||
lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
}*/
|
|
||||||
//alert(selectableLayers[i].name)
|
|
||||||
}
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
//lists[i].add('item',selectableLayers[i].index+"."+selectableLayers[i].name);
|
|
||||||
}
|
|
||||||
//var selIndex = sel[0].index-1;
|
|
||||||
lst_layer.selection = 0;
|
|
||||||
lst_pa.selection = 0;
|
|
||||||
lst_pb.selection = 0;
|
|
||||||
}
|
|
||||||
//build_yEntreDeux_UI();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
|
||||||
/*
|
|
||||||
function build_yEntreDeux_data_UI(){
|
|
||||||
yEntreDeux_data.window = new Window (yEntreDeux_data.res);
|
|
||||||
yEntreDeux_data.window.show();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
yEntreDeux_data.activate = build_yEntreDeux_data_UI ;
|
|
||||||
|
|
||||||
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
|
|
||||||
if (typeof(yToolBox_data)=='undefined'){
|
|
||||||
yEntreDeux_data.activate();
|
|
||||||
}else{
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user