View Full Version : MEL scripts
butCherHeLL 02-09-2007, 01:15 PM source removeWebButton.mel;//add this line to userSetup.mel
http://img206.imageshack.us/img206/8286/removewebbuttonol0.gif
|
|
butCherHeLL
02-09-2007, 01:16 PM
updated
a weird refresh bug in XP fixed.
little code, but it clears one of your annoyance in maya Interface;
source toggleDblShelf.mel;//add mel in scripts path.add this line to userSetup.mel.run maya.
http://img212.imageshack.us/img212/2714/toggledblshelfxg1.gif
butCherHeLL
02-15-2007, 01:46 PM
this is a way for debugging to mel scripters//easy print variables without writing dirty //print blabla codes.
works in 8.5
not before
http://www.ddmel.com/images/debugger.gif
global proc ktPrintSelected()
{
global string $gCommandExecuterTabs;
string $array[] = `tabLayout -q -ca $gCommandExecuterTabs`;
int $selTabIdx = `tabLayout -q -selectTabIndex $gCommandExecuterTabs` - 1;
string $curFormLayout = $array[$selTabIdx];
string $tabChldrn[] = `formLayout -q -ca $curFormLayout`;
string $curExecuter = $tabChldrn[0];
string $ktPrintSel=`cmdScrollFieldExecuter -q -slt $curExecuter`;
eval ("print " + $ktPrintSel);
};
butCherHeLL
03-04-2007, 08:23 PM
if a few a description is a need:
useful if you assign a hotkey.or as a shelf button.
when you need to select similar objects as your current selected nodes.
(ie. select a subd in scene.this tinycode will select all subds in scene.)
http://www.picturetrunk.com/2007/03042007/220eb94e89.gif
http://www.ddmel.com/miscfiles/ktSelectSimilars.mel (http://www.ddmel.com/miscfiles/ktSelectSimilars.mel)
proc j3dExpandTopNodeAndFrameInHyperGraph(string $nodes[], string $hyperPanel)
{
for ($node in $nodes ) {
string $cur = `firstParentOf($node)`;
string $next = $cur;
while($cur != "") {
if (j3dNodeHasConnection($cur, "hyperGraphLayout")) {
$next = `firstParentOf($cur)`;
if (`size($next)`) {
if (j3dNodeHasConnection($next, "hyperGraphLayout")) {
$cur = $next;
continue;
}
}
break;
}
else
$cur = `firstParentOf($cur)`;
}
if ($cur != "") {
select $cur;
hyperGraph -e -ua $hyperPanel;
}
}
select $nodes;
hyperGraph -e -fr $hyperPanel;
}
global proc int j3dNodeHasConnection(string $node, string $connection)
{
string $cons[] = `listConnections $node`;
string $cat = `j3dConcatenateStringArray($cons)`;
if ( size(`match $connection $cat`) )
return 1;
else
return 0;
}
global proc string j3dConcatenateStringArray(string $arr[])
{
string $ret;
for ($entry in $arr) {
$ret = $ret + $entry + " ";
}
return $ret;
}
global proc j3dFrameSelected()
{
string $panel = `getPanel -underPointer`;
if ( size(`match hyperGraphPanel $panel`) ) {
$panel += "HyperGraphEd";
string $sel[] = `ls -sl`;
j3dExpandTopNodeAndFrameInHyperGraph($sel, $panel);
}
fitPanel -selected;
}
global proc j3dUtils()
{
nameCommand -annotation "j3d Frame Selected" -command "j3dFrameSelected();" j3dFrameSelectedCommand;
hotkey -k "f" -name "j3dFrameSelectedCommand";
}
j3dUtils();
//----------------------------------------------------------------------
// proc cookie recipe
// this is a recipe for delicious chocolate chip cookies
//----------------------------------------------------------------------
// Soft Chocolate Chip Cookies
// Ingredients:
// 3/4 cup unsalted butter;
// 2/3 cup dark brown sugar;
// 2/3 cup granulated sugar;
// 2 tbsps light corn syrup;
// 1 tbsp cider vinegar or white vinegar;
// 2 large eggs;
// 1 tbsp vanilla;
// 1/2 tsp salt;
// 1/2 tsp baking powder;
// 1/4 tsp baking soda;
// 2-1/4 cup flour;
// 3 cups semisweet choc chips.
// Preheat oven to 375
// Grease baking sheets
// Cream together butter, sugars, corn syrup & vinegar, and then beat in the eggs.
// Beat in vanilla, salt, baking powder & baking soda.
// Stir in flour & chocolate chips.
// Drop dough by tablespoon-full on sheets.
// Cook for 10 minutes, so centers look underdone.
// Note: I usually make the cookies bigger.
//----------------------------------------------------------------------
butCherHeLL
03-10-2007, 05:38 PM
http://www.ddmel.com/mels/ktAssignNextShade/ktAssignNextShader.png
changes selected object's materials sequentially
assign this code to a hotkey ( I use Ctrl + (+) )
source ktAssignNextShader;
http://www.ddmel.com/mels/ktAssignNextShade/ktAssignNextShade.rar (http://www.ddmel.com/mels/ktAssignNextShade/ktAssignNextShade.rar)
(http://www.ddmel.com/mels/ktAssignNextShade/ktAssignNextShader.rar)http://www.ddmel.com/mels/ktAssignNextShade/ktAssignNextShader.gif
butCherHeLL
03-17-2007, 07:32 AM
http://www.ddmel.com/mels/ktUIDisplayLayer/ktUIDisplayLayer.gif
ktUIDisplayLayer.mel (http://www.ddmel.com/forum/index.php?topic=35.0)
Description:Adds some extra useful buttons to Display Layer
update #1@25.03.2007~16:04pm (select layer by object button added)
Firas
03-18-2007, 06:26 AM
man ... ktUIDispayLayer.mel (http://www.ddmel.com/mels/ktUIDispayLayer.mel) is wonderfull ..
***** :thumbsup:
gaiXyn
03-26-2007, 06:15 PM
hi...I'm looking for a spinEdge script...not the spinQuad one where you have to select twoQuads...but the one where you only need to select the edge that's shared by the twoQuads......anyHelp?
one that would spinAround faces that are "not" 4Sided would be nice too...does anyone know where I can find something like that?
I did a search for it already, but the links that suppose to lead to them all seem to be broken.....
ltr-
butCherHeLL
03-27-2007, 10:29 PM
auto lookat selection .mimics as modo or zbrush style.
when you auto mode:
you will autofocus to selected stuff.it can be anything.
it will speed up usage of maya sometimes.
because you are free to press ' f ' button next to zoom scene.
usage:
toggle_ktCurViewLookAt for on / off auto look at selection mode.
http://img262.imageshack.us/img262/6299/togglektcurviewlookatos7.gif
toggle_ktCurViewLookAt (http://www.ddmel.com/forum/index.php?topic=36.0)
butCherHeLL
04-04-2007, 06:17 AM
adds some extra buttons to timeslider.
what can be more here ? send some useful sugggestions.
http://img219.imageshack.us/img219/1922/ktuitimeslideren8.gif
http://img530.imageshack.us/img530/1148/untitledvx4.gif
DOWNLOAD (http://www.ddmel.com/forum/index.php?topic=38.0)
Firas
04-04-2007, 11:56 AM
hello ... thats very nice .. but personaly i rarly change the play rate time to duble or half ..
but i use alot "play evry frame" .. so for me this works better :)
Firas
04-04-2007, 12:49 PM
but butCherHeLL, after trying your way .. i think its much better :)
big thanks,
butCherHeLL
04-10-2007, 07:23 PM
http://m1.freeshare.us/131fs710321.gif
description:
This code is adds two extra menu items to the shelf's popup that
forces to increase or decrease rows of shelf.
once you setup the row,it maintains current row size for next start
if you are using toggledblShelf:
its strongly recommened to remove it.use this instead.
DOWNLOAD
http://www.ddmel.com/forum/index.php?topic=39.0
allenatl
04-23-2007, 01:30 PM
Creates a window that moves the pivot point to the last selected vertex position.
Good for rotating around the edge of an object instead of it's center
or rotating around another object's center.
Welcome any feedback on whether this is useful or if there's
an easier way already included in Maya.
/*
Name: acPivot.mel
Author: Allen Curtis
Date: April 2007
Description:
Moves pivot point to last selected vertex position.
Instructions:
1.Select vertex of an object.
2.Press the Point Position button. Shows xyz position.
3.Switch to object mode.
4.Press the Move Pivot button. Pivot moves to new position.
*/
string $getCurrentSelected[];
float $positionNow[];
global proc acPivot(){
if(`window -exists acPivotWindow`)
deleteUI acPivotWindow;
window -wh 200 200 -title "Move Pivot" acPivotWindow;
columnLayout -columnOffset "left" 15 -rs 5 ColumnLayout;
//Controls for viewing position of current selection.
text -label "Selection" -m 1 SelectionLabel;
text -label "x:" -align "left" labelX;
text -label "y:" -align "left" labelY;
text -label "z:" -align "left" labelZ;
text -label "Point Position" -align "left" labelPointMessage;
button -label "Point Position" -command "updateSelection" CurrentSelButton;
button -label "Move Pivot" -command "acMovePivot" MovePivotButton;
//These floatFieldGrp's are invisible. Their only purpose here is
//to use their precision flag as a round-off function for text labels.
//-m/manage flag used for invisibility.
floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffX;
floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffY;
floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffZ;
showWindow acPivotWindow;
}
//Moves pivot point to same position as last Point Position setting.
//Switch to object mode before pressing the Move Pivot button.
global proc acMovePivot(){
string $sel[] =`ls -sl`;
string $alignxToPt[];
string $alignyToPt[];
string $alignzToPt[];
float $x;
float $y;
float $z;
string $xvalue = `text -q -label labelX`;
//Tokenize separates the string into an array.
string $tokenX = `tokenize $xvalue ":" $alignxToPt`;
//Could have made an extra float variable here, but string automatically casts (converts) to
//a float value.
$x = $alignxToPt[1];
string $yvalue = `text -q -label labelY`;
string $tokenY = `tokenize $yvalue ":" $alignyToPt`;
$y = $alignyToPt[1];
string $zvalue = `text -q -label labelZ`;
string $tokenZ = `tokenize $zvalue ":" $alignzToPt`;
$z = $alignzToPt[1];
float $pos[3] = `xform -ws -rp $x $y $z`;
for ($current in $sel)
{
setAttr ($current + ".displayRotatePivot") 1;
};
}
ebotter
04-25-2007, 11:35 PM
I would like to have a mel which would snap UVs together. I couldn't not find it anywhere so I decided to post it here and see if someone who knows how to write a Mel could create this to help to make a better world ; ) for those who work with UVs.
Here what I have in mind: I have maya 7.0
If I select one UV - in UV Texture Editor window go to Select - Converte selection to Edges - (right the way) Select selection to UVs - like that all the UVs that are related will be selected. From here I think the deal would be to have a command which would save each of the original index # and the original position (U,V). I visualized a FloatSlider where we could control the distance just like "Merge Vertex Options". Also a right and left arrow which would have the function of select the UVs clockwise. Is it possible or it is just a dream?
Thanks.
Luddy
05-08-2007, 09:35 PM
This is the parent shape trick for selecting a joint by way of a control curve(s). You can also use objects with shape nodes.
{
$win = `window -title "ParentShape v1.1"`;
global proc pS()
{
string $curveJoint[] = `ls -sl`;
for($i=1;$i<size($curveJoint);++$i)
{
parent $curveJoint[$i] $curveJoint[0];
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $curveJoint[$i];
$curveShape=`listRelatives -shapes $curveJoint[$i]`;
parent -r -s $curveShape $curveJoint[0];
delete $curveJoint[$i];
}
}
columnLayout;
frameLayout -w 250 -cll true PARENTSHAPE;
columnLayout;
text - l "1. Select Joint";
text - l "2. Select Curve(s)";
button -c pS -l "ParentShape";
showWindow;
}
katisss
05-14-2007, 02:03 PM
Probably this is a really simple one:
I want a button with a really long label so it would be nice to have 2 lines
of text. Is it possible? "\n" doesn't work.
Another one: is there a way to set individual spacing for checkboxes in a vertical checkBoxGrp?
allenatl
05-24-2007, 02:55 AM
Dialog box for proportional scaling to a specific size.
http://www.allen3d.com/acScaler.jpg
//Name: acScaler.mel
//Author: Allen Curtis
//Email: allenatl@allen3d.com
//Date: May 20, 2007
//Revised: May 23, 2007
//Description: Dialog box for proportional scaling.
//Details:
//Proportional button scales x, y, and z values.
//Use in object mode. Select an object before opening window.
//Proportional Scale changes do not take effect until the Apply button is pressed.
//Reset Scale button resets scale to 1.0. Reset before entering a Desired Size.
//Freeze button makes the current size the new 1.0 scale.
//Check the Centimeters checkbox to scale to desired size in centimeters.
//Uncheck the Centimeters checkbox to scale to desired size in inches.
//Press the Prop. Scale button to preview proportional size change in the Inches
//or Centimeters textfields.
//Press the Apply button to apply the scale to the selected object.
//The selected object is scaled on the axis selected and the other two axes are scaled proportionately.
//Update button shows what is selected in a label at top of the acScaler window.
//Press the Update button to verify the current selection.
//Edit Sliders button adjusts sliders maximum, minimum, and step values.
//Undoing doesn't update bounding box fields. Click the update button after undoing.
global string $getSelected[];
global proc acScaler(){
$getSelected=`ls -sl`;
if(size(`filterExpand -sm 9 -sm 10 -sm 12 -sm 68 -sm 72`)>0){
if(`window -exists acScaleWindow`)
deleteUI acScaleWindow;
window -widthHeight 300 200 -title "acScaler" -rtf true acScaleWindow;
//This outer formLayout was only added for better alignment of bottom and top elements
//Using attachForm with a larger offset centered the upper ColumnLayout better.
string $outerLayout = `formLayout -numberOfDivisions 100`;
columnLayout -columnAttach "left" 10 -columnOffset "both" 5 -rs 5 ColumnLayout;
//Controls for viewing position of current selection.
text -label "Selection" SelectionLabel;
text -edit
-label ("Selection: " + $getSelected[0] + " :1 of " + size($getSelected) + " selected")
SelectionLabel;
floatFieldGrp -numberOfFields 3 -label "Size in Centimeters:" -v1 1.0 -v2 1.0 -v3 1.0
-pre 6 -en false boxCtField;
floatFieldGrp -numberOfFields 3 -label "Size in Inches:" -v1 1.0 -v2 1.0 -v3 1.0
-pre 6 -en true boxInchField;
floatFieldGrp -numberOfFields 3 -label "BoundingBoxMin:" -v1 0.0 -v2 0.0 -v3 0.0
-pre 6 -en false boxMinField;
floatFieldGrp -numberOfFields 3 -label "BoundingBoxMax:" -v1 0.0 -v2 0.0 -v3 0.0
-pre 6 -en false boxMaxField;
//The -at flag determines what attributes are affected by sliders.
attrFieldSliderGrp -min .01 -max 100 -step 0.01 -pre 6
-at ($getSelected[0] +".sx")-cc "showBBox" xSlider;
attrFieldSliderGrp -min .01 -max 100 -step 0.01 -pre 6
-at ($getSelected[0] + ".sy")-cc "showBBox" ySlider;
attrFieldSliderGrp -min .01 -max 100 -step 0.01 -pre 6
-at ($getSelected[0] + ".sz") -cc "showBBox" zSlider;
floatFieldGrp -nf 1 -l "Proportional Scale:" -v1 1.0 -pre 6 propScaleField;
//Layout nested inside another layout.
rowLayout -numberOfColumns 7 MainRowLayout;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column1;//Spacing
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column2;
button -label "Update" -c "showBBox" UpdateButton;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column3;
button -label "Apply" -c "acPropScale" PropButton;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column4;
button -label "Close" -c "deleteUI acScaleWindow" ExitButton;
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent MainRowLayout Column5;//Spacing
columnLayout -columnAttach "both" 5 -rowSpacing 10 -parent ColumnLayout CheckBoxColumn;
checkBox -label "Centimeters" -value 0 checkCentimeters;
string $form = `formLayout -numberOfDivisions 100 -parent $outerLayout`;
columnLayout -adjustableColumn false -parent $form ScaledColumnLayout;
floatFieldGrp -nf 1 -l "Desired Size:" -v1 1.0 -pre 6 scaledSizeField;
columnLayout -adjustableColumn false -parent $form SizeButtonColumnLayout;
button -label "Prop. Scale" -align "center" -width 80 -c "desiredScaleSize" SizeButton;
columnLayout -adjustableColumn false -parent $form ResetButtonColumnLayout;
button -label "Reset Scale" -align "center" -width 80 -c "resetScaleToOne" ResetButton;
columnLayout -adjustableColumn false -parent $form FreezeButtonColumnLayout;
button -label "Freeze Scale" -align "center" -width 80
-c "makeIdentity -apply true -t 0 -r 0 -s 1 -n 0" FreezeButton;
columnLayout -adjustableColumn false -parent $form AxisColumnLayout;
radioButtonGrp -numberOfRadioButtons 3 -columnAlign 1 "left"
-columnWidth 1 60 -columnWidth 2 80 -label "Axis:"
-labelArray3 "x" "y" "z" -sl 2 radioScaledSize;
columnLayout -adjustableColumn false -parent $form EditSliderLayout;
floatFieldGrp -nf 3 -l "Sliders Min/Max/Step:" -v1 .01 -v2 100 -v3 .01 -pre 6 editSlidersField;
columnLayout -adjustableColumn false -parent $form SliderButtonLayout;
button -label "Edit Sliders" -c "editSliders" SliderButton;
formLayout -edit
-attachForm ScaledColumnLayout "top" 5
-attachForm ScaledColumnLayout "left" 5
-attachControl ScaledColumnLayout "bottom" 10 AxisColumnLayout
-attachOppositeControl SizeButtonColumnLayout "top" 5 ScaledColumnLayout
-attachControl SizeButtonColumnLayout "left" 10 ScaledColumnLayout
-attachControl SizeButtonColumnLayout "bottom" 10 AxisColumnLayout
-attachOppositeControl ResetButtonColumnLayout "top" 5 ScaledColumnLayout
-attachControl ResetButtonColumnLayout "left" 5 SizeButtonColumnLayout
-attachControl ResetButtonColumnLayout "bottom" 10 AxisColumnLayout
-attachOppositeControl FreezeButtonColumnLayout "top" 5 ScaledColumnLayout
-attachControl FreezeButtonColumnLayout "left" 5 ResetButtonColumnLayout
-attachControl FreezeButtonColumnLayout "bottom" 10 AxisColumnLayout
-attachNone AxisColumnLayout "top"
-attachForm AxisColumnLayout "right" 15
-attachControl AxisColumnLayout "bottom" 10 EditSliderLayout
-attachNone EditSliderLayout "top"
-attachForm EditSliderLayout "left" 5
-attachForm EditSliderLayout "bottom" 10
-attachNone SliderButtonLayout "top"
-attachForm SliderButtonLayout "right" 5
-attachForm SliderButtonLayout "bottom" 10
$form;
formLayout -edit
-attachForm ColumnLayout "top" 5
-attachForm ColumnLayout "left" 28
-attachForm $form "bottom" 5
-attachForm $form "left" 5
$outerLayout;
window -edit -widthHeight 538 524 acScaleWindow;
showWindow acScaleWindow;
}else{
confirmDialog -title "acScaler: Selection Type"
-message "Select a Polygon, Subdiv, or NURBS Object before opening acScaler."
-button "OK";
}//end else
}
global proc acPropScale(){
float $getValue = `floatFieldGrp -q -v1 propScaleField`;
scale $getValue $getValue $getValue ;
showBBox;
}
global proc showBBox(){
$getSelected =`ls -sl`;
if(size(`filterExpand -sm 9 -sm 10 -sm 12 -sm 68 -sm 72`)>0){
string $attr = $getSelected[0] + ".boundingBoxSize";
float $value[]= `getAttr $attr`;
float $selNumber = size($getSelected);
if ($selNumber>1){
text -edit
-label
("Multiple selections: " + $getSelected[0] + " :1 of " + $selNumber +
". Unexpected results possible.")
SelectionLabel;
}else{
text -edit
-label ("Selection: " + $getSelected[0] + " :1 of " + $selNumber + " selected")
SelectionLabel;
}
floatFieldGrp -edit -v1 $value[0] boxCtField;
floatFieldGrp -edit -v2 $value[1] boxCtField;
floatFieldGrp -edit -v3 $value[2] boxCtField;
$attr = $getSelected[0] + ".boundingBoxMax";
float $conversion = 0.3937;
float $inch= $value[0] * $conversion;
floatFieldGrp -edit -v1 $inch boxInchField;
$inch= $value[1] * $conversion;
floatFieldGrp -edit -v2 $inch boxInchField;
$inch= $value[2] * $conversion;
floatFieldGrp -edit -v3 $inch boxInchField;
$attr = $getSelected[0] + ".boundingBoxMin";
$value = `getAttr $attr`;
floatFieldGrp -edit -v1 $value[0] boxMinField;
floatFieldGrp -edit -v2 $value[1] boxMinField;
floatFieldGrp -edit -v3 $value[2] boxMinField;
$attr = $getSelected[0] + ".boundingBoxMax";
$value = `getAttr $attr`;
floatFieldGrp -edit -v1 $value[0] boxMaxField;
floatFieldGrp -edit -v2 $value[1] boxMaxField;
floatFieldGrp -edit -v3 $value[2] boxMaxField;
float $editMin = `floatFieldGrp -q -v1 editSlidersField`;
float $editMax = `floatFieldGrp -q -v2 editSlidersField`;
float $editStep = `floatFieldGrp -q -v3 editSlidersField`;
//Update sliders when a new selection is made.
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] +".sx") xSlider;
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] + ".sy") ySlider;
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] + ".sz") zSlider;
}else{
confirmDialog -title "acScaler: Selection Type"
-message "Select Polygon, Subdiv, or NURBS Object Type."
-button "OK";
}//end else
}//end proc
global proc editSliders(){
$getSelected =`ls -sl`;
if(size(`filterExpand -sm 9 -sm 10 -sm 12 -sm 68 -sm 72`)>0){
float $editMin = `floatFieldGrp -q -v1 editSlidersField`;
float $editMax = `floatFieldGrp -q -v2 editSlidersField`;
float $editStep = `floatFieldGrp -q -v3 editSlidersField`;
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] +".sx") xSlider;
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] + ".sy") ySlider;
attrFieldSliderGrp -edit -min $editMin -max $editMax -step $editStep
-at ($getSelected[0] + ".sz") zSlider;
}else{
confirmDialog -title "acScaler: Selection Type"
-message "Select Polygon, Subdiv, or NURBS Object Type."
-button "OK";
}//end else
}
global proc desiredScaleSize(){
float $getXValue;
float $getYValue;
float $getZValue;
float $setDesiredValue = `floatFieldGrp -q -v1 scaledSizeField`;
float $getProp = `floatFieldGrp -q -v1 propScaleField`;
int $inchOrMetric=`checkBox -query -value checkCentimeters`;
if($inchOrMetric==0){
floatFieldGrp -edit -en false boxCtField;
floatFieldGrp -edit -en true boxInchField;
$getXValue = `floatFieldGrp -q -v1 boxInchField`;
$getYValue = `floatFieldGrp -q -v2 boxInchField`;
$getZValue = `floatFieldGrp -q -v3 boxInchField`;
}else if($inchOrMetric==1){
floatFieldGrp -edit -en true boxCtField;
floatFieldGrp -edit -en false boxInchField;
$getXValue = `floatFieldGrp -q -v1 boxCtField`;
$getYValue = `floatFieldGrp -q -v2 boxCtField`;
$getZValue = `floatFieldGrp -q -v3 boxCtField`;
}
int $radioAxis = `radioButtonGrp -q -sl radioScaledSize`;
float $percent;
float $setXSize;
float $setYSize;
float $setZSize;
//x axis selected
if(($radioAxis==1) && ($getProp==1.0)){
if($getXValue==0){//inner if else
confirmDialog -title "acScaler: Scaling Message"
-message "Size on X axis is 0. Select another axis for desired size."
-button "OK";}else{
$percent = $setDesiredValue/$getXValue;
$setYSize = $getYValue * $percent;
$setZSize = $getZValue * $percent;
string $changePercent = `floatFieldGrp -edit -v1 $percent propScaleField`;
if($inchOrMetric==0){ //nested if
floatFieldGrp -edit -v1 $setDesiredValue boxInchField;
floatFieldGrp -edit -v2 $setYSize boxInchField;
floatFieldGrp -edit -v3 $setZSize boxInchField;
}else if($inchOrMetric==1){
floatFieldGrp -edit -v1 $setDesiredValue boxCtField;
floatFieldGrp -edit -v2 $setYSize boxCtField;
floatFieldGrp -edit -v3 $setZSize boxCtField;
}//nested if ends
}//inner if else ends
//y axix selected
}else if(($radioAxis==2) && ($getProp==1.0)){
if($getYValue==0){//inner if else
confirmDialog -title "acScaler: Scaling Message"
-message "Size on Y axis is 0. Select another axis for desired size."
-button "OK";}else{
$percent = $setDesiredValue/$getYValue;
$setXSize = $getXValue * $percent;
$setZSize = $getZValue * $percent;
string $changePercent = `floatFieldGrp -edit -v1 $percent propScaleField`;
if($inchOrMetric==0){//nested if
floatFieldGrp -edit -v1 $setXSize boxInchField;
floatFieldGrp -edit -v2 $setDesiredValue boxInchField;
floatFieldGrp -edit -v3 $setZSize boxInchField;
}else if($inchOrMetric==1){
floatFieldGrp -edit -v1 $setXSize boxCtField;
floatFieldGrp -edit -v2 $setDesiredValue boxCtField;
floatFieldGrp -edit -v3 $setZSize boxCtField;
}//nested if ends
}//inner if else ends
//z axis selected
}else if(($radioAxis==3) && ($getProp==1.0)){
if($getZValue==0){//inner if else
confirmDialog -title "acScaler: Scaling Message"
-message "Size on Z axis is 0. Select another axis for desired size."
-button "OK";}else{
$percent = $setDesiredValue/$getZValue;
$setXSize = $getXValue * $percent;
$setYSize = $getYValue * $percent;
string $changePercent = `floatFieldGrp -edit -v1 $percent propScaleField`;
if($inchOrMetric==0){//nested if
floatFieldGrp -edit -v1 $setXSize boxInchField;
floatFieldGrp -edit -v2 $setYSize boxInchField;
floatFieldGrp -edit -v3 $setDesiredValue boxInchField;
}else if($inchOrMetric==1){
floatFieldGrp -edit -v1 $setXSize boxCtField;
floatFieldGrp -edit -v2 $setYSize boxCtField;
floatFieldGrp -edit -v3 $setDesiredValue boxCtField;
}//nested if ends
}//inner if else ends
}else{
confirmDialog -title "acScaler: Scaling Message"
-message "Reset Scale before entering desired size."
-button "OK";
}
}
global proc resetScaleToOne(){
floatFieldGrp -edit -v1 1.0 propScaleField;
acPropScale;
}
eranicle
06-07-2007, 05:13 AM
hi everyone!
i'm newibe in MEL, therefore dont judge me too much, please :)
there's some script i've written foк easier tuning of DOF in Maya. It works both in maya software & mental ray renderers (the only difference that in mental you should decrease Fstop attribute approximately 50 %).
this script creates camera and two locators, one of which (the biggest) has attributes DOFdepth (for determining which focus distance you need) and Lscale (for comfort).
!dont translate it with moveTool!
examples:
locator along with first sphere:
http://forums.cgsociety.org/attachment.php?attachmentid=114372&stc=1
locator along with second sphere:
http://forums.cgsociety.org/attachment.php?attachmentid=114373&stc=1[/url]
locator along with third sphere:
http://forums.cgsociety.org/attachment.php?attachmentid=114374&stc=1[url="http://forums.cgsociety.org/attachment.php?attachmentid=114374&stc=1"] (http://forums.cgsociety.org/attachment.php?attachmentid=114373&stc=1)
script:
//// eraDOFcamera //// created by eranicle <Artur Kamalov>
//// creating camera
camera -n "eraDOFcam1"
-depthOfField true
-displayResolution true
-displaySafeAction true
-displayFilmPivot true;
setAttr "eraDOFcam1Shape1.overscan" 1.3;
setAttr "eraDOFcam1Shape1.fStop" 2;
//// creating distance dimension
spaceLocator -n "DOFlocator1" -p 0 0 0;
spaceLocator -n "DOFlocator2" -p 0 0 -7;
addAttr -keyable true -ln "lScaleX" -at "float" DOFlocator2;
connectAttr DOFlocator2.lScaleX DOFlocator2Shape.localScaleX;
addAttr -keyable true -ln "lScaleY" -at "float" DOFlocator2;
connectAttr DOFlocator2.lScaleY DOFlocator2Shape.localScaleY;
addAttr -keyable true -ln "lScaleZ" -at "float" DOFlocator2;
connectAttr DOFlocator2.lScaleZ DOFlocator2Shape.localScaleZ;
setAttr DOFlocator2.lScaleX 5;
setAttr DOFlocator2.lScaleY 5;
setAttr DOFlocator2.lScaleZ 5;
distanceDimension -sp 0 0 0 -ep 0 0 -7;
//// parenting first DOFlocator to cam
select -r eraDOFcam1;
select -tgl DOFlocator1 ;
pointConstraint -offset 0 0 0 -weight 1;
//// parenting second DOFlocator to cam
select -r eraDOFcam1;
select -tgl DOFlocator2 ;
parentConstraint -mo -weight 1;
//// adding new "depth" attribute to DOFlocator
addAttr -ln "DOFdepth" -keyable true DOFlocator2;
connectAttr DOFlocator2.DOFdepth DOFlocator2Shape.localPositionZ;
//// some improvements
setAttr DOFlocator2.DOFdepth -7;
setAttr -lock true "DOFlocator2.sx";
setAttr -lock true "DOFlocator2.sy";
setAttr -lock true "DOFlocator2.sz";
setAttr -keyable false "DOFlocator2.sx";
setAttr -keyable false "DOFlocator2.sy";
setAttr -keyable false "DOFlocator2.sz";
setAttr -keyable false "DOFlocator2.rx";
setAttr -keyable false "DOFlocator2.ry";
setAttr -keyable false "DOFlocator2.rz";
setAttr -keyable false "DOFlocator2.tx";
setAttr -keyable false "DOFlocator2.ty";
setAttr -keyable false "DOFlocator2.tz";
//// connecting loator's DOFdepth to camera focusDistance
connectAttr -f distanceDimensionShape1.distance eraDOFcam1Shape1.focusDistance;
//// for comfort work
TwoSideBySideViewArrangement;
lookThroughModelPanel persp modelPanel1;
lookThroughModelPanel eraDOFcam1 modelPanel4;
//// end
instruct9r
08-28-2007, 08:32 AM
Add many attributes at one time.... There's also "vector Int" and Vector Float.....
You can also do soft Min and Max....
Download from :
http://puppetTD.com (http://puppetTD.com) ---> Downloads
http://puppettd.com/images/dgAddAttrs.jpg
Download from : http://puppetTD.com (http://puppetTD.com) ----> Downloads
OviBogdan
08-28-2007, 07:32 PM
hi, im looking for a script that allows me to change the color attribute for multiple shaders at one time. or possibly just setting the color attribute to black. i have a big scene with many shaders and im trying to get a reflection pass and i do not want to lose any of my reflection attributes.
thanks
instruct9r
10-14-2007, 01:19 AM
dgCopyKeys.mel is nice little script that is copying keys from the first select object to all others... It offset the keys for every object (from the previous one) by the specified values
http://puppettd.com/ (http://puppettd.com/) ->> Downloads
http://puppettd.com/images/dgCopyKeys.jpg
swapnil3d
10-23-2007, 06:53 PM
global proc TransferShaders()
{
//we need to select the first object
string $Opt_Obj[]=`ls - selection`;
//select the first object
select $Opt_Obj[0];
//get list of shaders assigned to it
hyperShade -smn "";
//now select the first shader and do select object with materils
string $Opt_Shd[]=`ls - selection`;
int $no_Shd = `size $Opt_Shd`;
int $input = 0;
////////////////////////////////////////////////////////////////////////////////////
while ( $input <= $no_Shd-1)
{
int $r = $input++;
print $r;
select $Opt_Shd[$r];
//we havr selected particular shader in the row let us now
//select the faces through that shaders
hyperShade -objects "";
//lets list the selection
string $Opt_Face[]=`ls -selection`;
///Replace the name from 1st to 2nd object/////////////////////////////////
string $Opt_Name1[]={$Opt_Obj[0]};
string $Opt_Name2[]={$Opt_Obj[1]};
//////////////////////////////////////////////////////////////////////////////
int $Opt_F_Siz= `size $Opt_Face`;
int $input_Shd = 0;
//get the name of the slected current face
while ( $input_Shd <= $Opt_F_Siz-1)
{
int $t = $input_Shd++;
print $t;
select $Opt_Face[$t];
string $Opt_Face_S=`fileExtension ($Opt_Face[$t])`;
//rename with new object///////////////////////////////////////////
string $Opt_Arrange[]={$Opt_Name2[0] +"."+ $Opt_Face_S};
///////// Assign shaders ////////////////////////////////////////////
select $Opt_Arrange[0];
hyperShade -assign $Opt_Shd[$r];
}
}
};
swapnil3d
10-23-2007, 07:02 PM
select the vertex and execute ...
//#############################################################################//
///////////////////// { Create Sprite on Selected Vertce }///////////////////////
//#############################################################################//
//////////////////////( Procedure is declared )/////////////////////////////////
global proc createSprite()
{
string $MySel[]= `ls -selection`;
int $siz = `size ( $MySel )`;
if ($siz >= 2 )
{
warning "there are more than one vertice or object selected / Select one vertice at a Time ";
}
else
{
string $h[]={ $MySel[0]};
vector $ror = `xform -q -wd -t ($h)`;
string $fgh[0] =
`polyPlane
-n "Sprite"
-w .1
-h .1
-sx 1
-sy 1
-ax 0 0 1
-tx 1
-ch 0`;
//////////move the pivot down and sprite up///////////////////////
move
-r 0 -0.05 0 $fgh.scalePivot $fgh.rotatePivot ;
move ($ror.x,$ror.y,$ror.z);
move -r 0 0.05 0 ;
/////////////////////////////////////////////////////////////////////
}
;
}
swapnil3d
10-23-2007, 07:23 PM
//########################################################################################//
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
/* This file was created for the Use of all 3D Artist for managing thier files to work
effeciently
'' Script Name: MAYA_PROJECT_MANAGER
'' Author: Swapnil Halarnkar ( OPTIK )
''
'' Please do not alter any information above this line
*/
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// Procedure Name : MAYA_PROJECT_MANAGER ///
/// Created : january 23 2007 ///
/// Last Updated: ///
/// ///
/// Author : Swapnil Halarnkar ///
/// Contact : swapnil_artist@yahoo.co.in (http://forums.cgsociety.org/swapnil_artist@yahoo.co.in) ///
/// ///
/// Description : ///
/// 1) This procedure will set all the camera renderable to "0" ///
/// 2) Also your desire camera to be renderable ///
/// 3)*NOTE : only the active camera will become renderable or ///
/// remain renderable ///
/// 5) the total folder need to be copied to D:/ sky_Tools ///
/// or scripts wont excute
/// 4) This is my Second script Job , to preserve it its my
/// first step ///
/// ///
/// How to use : ///
/// ///
/// Put the script in your scripts folder then type and execute ///
/// "CamRenderActive" in the command line or Script Editor, ///
/// an UI window will appear. Then follow the help in the UI ///
/// window to finish your job. ///
/// ///
/// Inputs : None ///
/// script : Script 2 ( Automation + Effeciency ) ///
/// Return : None ///
/// Credits : /// ///
/// All Rights Reserved . ///
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//########################################################################################//
////////////////
// MEL Starts //
////////////////
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//########################################################################################//
////////////////////////////////////////////////////////////////////////////////////////////
////////////////// {THE PROCEDURE MAYA PROJECT MANAGER DECLARED}////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
//########################################################################################//
global proc MAYA_PROJECT_MANAGER()
{
////////////////// {THE WINDOW AND LAYOUT DECLARED}/////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
//########################################################################################//
string $MPM = `window
-t "MAYA_PROJECT_MANAGER ® Scripting by: OPTIK "
//########################################################################################//
- wh 520 500`;
scrollLayout;setParent;
////////////////// {THE FIRST SECTION OF SHADERS} //////////////////////////////////////////
/////////////////////////////{Fabric}///////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Fabric/"`;
string $PM[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Fabric/"`;
int $Pic_No = `size $PF`;
int $inputNo = 0 ;
string $tabs = `tabLayout -innerMarginWidth 5 -innerMarginHeight 5 -childResizable 1`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
string $child1 = `columnLayout -adjustableColumn 1 `;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Fabric "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r]
-c "file -import $PM[$r]"; ;
}
setParent ..; setParent ..;
////////////////// {THE SECOND SECTION OF SHADERS} /////////////////////////////////////////
///////////////////////////{ Furs }//////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Furs/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Furs "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r]
-c ("file -import $PF[$r]");
}
setParent ..; setParent ..;
////////////////// {THE THIRD SECTION OF SHADERS} /////////////////////////////////////////
////////////////////////{ GLASS }/////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Glass/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Glass "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE FOURTH SECTION OF SHADERS} /////////////////////////////////////////
//////////////////////////{ LIQUID }////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Liquid/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Liquid "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE FIFTH SECTION OF SHADERS} /////////////////////////////////////////
//////////////////////////{ METALS }///////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Metals/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Metals "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE SIXTH SECTION OF SHADERS} /////////////////////////////////////////
////////////////////////{ ORGANIC }////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Organic/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Organic "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE SEVENTH SECTION OF SHADERS} /////////////////////////////////////////
/////////////////////////{ ROCKS }///////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Rocks/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Rocks "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE EIGHTTH SECTION OF SHADERS} /////////////////////////////////////////
///////////////////////////{ VELVET }////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Velvet/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Velvet "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE NINTH SECTION OF SHADERS} /////////////////////////////////////////
/////////////////////////////{ WOODS }/////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Woods/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Woods "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE TENTH SECTION OF SHADERS} //////////////////////////////////////////
////////////////////////////{ GENERIC }/////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Generic/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label "Generic "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE ELEVENTH SECTION OF SHADERS} /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Generic/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label " "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE TWELTH SECTION OF SHADERS} /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Generic/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label " "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..;
////////////////// {THE THIRTEENTH SECTION OF SHADERS} /////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Shaders/icons/Generic/"`;
int $Pic_No = `size $PF`;
string $AnT[]= {"There are " + $Pic_No + " Shaders" };
int $inputNo = 0 ;
frameLayout
-ann $AnT
-bgc 0 0 0.363
-w 440
-label " "
-cll true
-cl 1
-bs "etchedOut";
rowColumnLayout
-nc 5
-cw 1 80
-cw 2 80
-cw 3 80
-cw 4 80
-cw 5 80;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
symbolButton
-image $PF[$r]
-bgc 0 0 0
-ann $PF[$r] ;
}
setParent ..; setParent ..; setParent ..;
///////////////////////////edit the tab /////////////////////////////////////////////////
tabLayout -edit
-tabLabel $child1 "Shaders"
$tabs;
//########################################################################################//
//////////////////////////////// {TAB THIRD} ///////////////////////////////////////////////
//////////////////////////////{FILES TO IMPORT//////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/Library/Import/"`;
int $Pic_No = `size $PF`;
int $inputNo = 0 ;
string $child2 = `columnLayout -adjustableColumn true`;
frameLayout
-bgc 0 0 0.363
-w 440
-label " Import File "
-cll true
-cl false
-bs "etchedOut";
rowColumnLayout -nc 1 -cw 1 400 ;
while ( $inputNo <= $Pic_No-1 )
{
int $r = $inputNo++;
string $j[]= `getFileList - folder "D:/Project_Manager/Library/import/"`;
string $path[] = {"D:/Project_Manager/mel/" +$j[0] };
string $fe = `encodeString $path[0]`;
string $qoute[]= {"\""};
string $icmm[] = {"file -import "+ $qoute[0] + "D:/Project_Manager/Library/import/" +$j[$r] + $qoute[0] };
button
-w 400
-h 20
-align "center"
-label $PF[$r]
-c $icmm;
}
setParent ..; setParent ..; setParent ..;
////////////////////////////////////////edit the tab ////////////////////////////////////////
tabLayout -edit
-tabLabel $child2 "Import"
$tabs;
////////////////////////////////////////////////////////////////////////////////////////////
//########################################################################################//
//////////////////////////////// {THE TAB THIRD } //////////////////////////////////////////
////////////////////////////////////{SCRIPTS }//////////////////////////////////////////////
string $PF[]= `getFileList -folder "D:/Project_Manager/mel/"`;
int $Pic_No = `size $PF`;
int $inputNo = 0 ;
string $child3 = `columnLayout -adjustableColumn true`;
frameLayout
-bgc 0 0 0.363
-w 440
-label "Scripts "
-cll true
-cl false
-bs "etchedOut";
rowColumnLayout
-nc 1
-cw 1 400 ;
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////MEL FOR SCRIPT EXECUTION ON BUTTON PRESS////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//GMP : GET MEL PATH
//GP : GOT PATH
//MSF : MEL SCRIPT FILE
//NMSF : NO MEL SCRIPT FILE
//KIT : ULTIMATE PROCEDURE NAME
//////////////////////////////////////////////////////////////////////////////////////////
$input2No=0;
string $GMP[]= `getFileList - folder "D:/Project_Manager/mel/" -filespec "*.mel"`;
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
int $NMSF = `size $GMP`;
//////////////////////////////////////////////////////////////////////////////////////////
while ( $input2No <= $NMSF-1 )
{
string $j[]= `getFileList - folder "D:/Project_Manager/mel/" -filespec "*.mel"`;
string $path[] = {"D:/Project_Manager/mel/" +$j[0] };
int $r= $input2No++;
string $f = $j[$r];
string $f = $j[$r];
string $gotj = `basenameEx $f`;
print $gotj;
button
-label $gotj
-align "center"
-ann $gotj
-c $gotj;
}
setParent ..; setParent ..; setParent ..;
////////////////////////////////////////edit the tab ///////////////////////////////////////
tabLayout -edit
-tabLabel $child3 "Scripts"
$tabs;
//########################################################################################//
//////////////////////////////// {THE TAB FIFTH} //////////////////////////////////////////
/////////////////////////////////{MY COMPUTER }//////////////////////////////////////////////
string $child12 = `columnLayout`;
//lets declare some procedures
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
columnLayout
-w 440 -h 500;
button
-l "My Computer"
-c MFT;
button
-l " Local D:/ "
-c DFT;
button
-l " PROJECT "
-c PFT;
button
-l " Local C:/ "
-c CFT;
$browser = `webBrowser -width 800 -height 600 -url "file:///D:/Project_Manager/"`;
setParent ..; setParent ..;
////////////////////////////////////////edit the tab ///////////////////////////////////////
tabLayout -edit
-tabLabel $child12 "Computer "
$tabs;
////////////////////////////////////////////////////// /////////////////////////////////////
//########################################################################################//
//////////////////////////////// {THE TAB FOURTH} //////////////////////////////////////////
////////////////////////////////////{ HELP }////////////////////////////////////////////////
// lets source the procedure
source "D:/Project_Manager/Library/Support scripts/DFT.mel";
source "D:/Project_Manager/Library/Support scripts/CFT.mel";
source "D:/Project_Manager/Library/Support scripts/MFT.mel";
source "D:/Project_Manager/Library/Support scripts/PFT.mel";
source "D:/Project_Manager/Library/Support scripts/credit.mel";
string $child15 = `columnLayout -adjustableColumn true `;
//adding some text matter for Help section
//made it into a Array and calling it with
//escape character to get into new line...
//-----------------------------TEXT MATTER STARTS---------------------------------------------//
string $line1[] =
{ " MAYA_PROJECT_MANAGER® Scripting by: OPTIK " ,
"---------------------- Author: Swapnil Halarnkar",
" DQ Entertainment PVT. LTD. ",
" --------------------------",
"",
"",
" *{ Maya Project Manager is designed for User Friendly ",
" acess , while the only limitation it offers is the ",
" path to where it needs to be set and ristricted to ",
" given folder Hirechy } ",
"",
"",
" Features : 1) important feature of this UI is its dynamic ",
" Usage. ",
" 2) copy whatever shaders and its respective BMP",
" with specified size in respective folders to",
" view and import on a click. ",
" 3) while Import section implies same features, ",
" the Script section shows and executes the ",
" script removing the necessity to source a ",
" Script. ",
" 4) Computer tab is kind of a browser from where ",
" U can acess drives on the system and also ",
" added features of Web Browser ",
" 5) MAYA Help section are for those who really ",
" thier careers seriously. ",
"",
"",
" How to Use : 1) Copy Project_Manager folder to D drive. ",
" 2) load shelf my shelf from the folder. ",
" 3) set Project to Project Manager folder. "};
scrollField -w 440 -h 450
-text ( $line1[0]+"\n"+ $line1[1]+"\n"+ $line1[2]+"\n"
+"\n"+$line1[3]+"\n"+ $line1[4]+"\n"+ $line1[5]
+"\n"+$line1[6]+"\n"+ $line1[7]+"\n"+ $line1[8]
+"\n"+ $line1[9]+"\n"+ $line1[10]+"\n"+ $line1[11]
+"\n"+ $line1[12]+"\n"+ $line1[13]+"\n"+ $line1[14]
+"\n"+ $line1[15]+"\n"+ $line1[16]+"\n"+ $line1[17]
+"\n"+ $line1[18]+"\n"+ $line1[19]+"\n"+ $line1[20]
+"\n"+ $line1[21]+"\n"+ $line1[22]+"\n"+ $line1[23]
+"\n"+ $line1[24]+"\n"+ $line1[25]+"\n"+ $line1[26]
+"\n"+ $line1[27]+"\n"+ $line1[28]+"\n"+ $line1[29]
+"\n"+ $line1[30]+"\n"+ $line1[31]+"\n"+ $line1[32])
//-----------------------------TEXT MATTER ENDS---------------------------------------------//
-editable false ;
separator
-hr 1
-w 440
-style "in";
button
-align "right"
-label " CREDITS "
-c credit;
scrollLayout;
setParent ..; setParent ..;
////////////////////////////////////////edit the tab ///////////////////////////////////////
tabLayout -edit
-tabLabel $child15 "Help "
$tabs;
////////////////////////////////////////////////////// /////////////////////////////////////
//////////////////////////////// {THE TAB FOURTH} //////////////////////////////////////////
////////////////////////////////////{MAYA HELP }//////////////////////////////////////////////
string $child14 = `columnLayout`;
$browser = `webBrowser -width 1280 -height 1024 -url "http://localhost:4449/Maya7.0/en_US/"`;
setParent ..; setParent ..;
////////////////////////////////////////edit the tab ///////////////////////////////////////
tabLayout -edit
-tabLabel $child14 "Maya Help "
$tabs;
////////////////////////////////////////////////////// /////////////////////////////////////
////////////////////////////////////////////////////// /////////////////////////////////////
////////////////////////////////////// {THE WINDOW IS SHOWN} ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
showWindow $MPM;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
////////////////
// MEL ENDS ////
////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
cagebee
12-04-2007, 01:09 PM
hai
i have attached a script that can be used to retain the target shapes even if you alter the base shape. Works on poly.
Useage:
select the base mesh and execute the script, it will prompt for a name of the shape (ex. sad, happt, eyb_blink_left...) , once u enter the name, a shape is created, now just sculpt the shape you want. Now when u alter the base mesh the target also changes accordingly.
plz try and let me know if it helped you someway.
NOTE: i have attached as txt file, plz change the extension to .mel,
thanks
neo420
01-02-2008, 05:15 PM
Hi guys,
I'm doing a project work & i need a mel script for dual resolution gate like i need both HD 1080 & PAL 768 shown at the same time. Here is an example in this image
http://img186.imageshack.us/img186/415/rg1cc0.jpg
With that red mark being a PAL 768 (768x576) standard. Can anyone please tell me the script for this, please.
swardson
03-22-2008, 07:43 PM
Hey all,
I have started compiling all of my scripts into a single area on my website. I wanted to post a link here to provide them to everyone who has already been so generous to me.
Some are more useful than others, but I have found them to be big time savers myself.
If you find problems with them or would like other features, please let me know and I will see what I can do.
http://www.swardson.com/melScripts
I am going to be updating the site regularly, so if you want to subscribe to the RSS you will get automatic updates as to when new scripts come available.
Thanks,
Brad
Boucha
03-23-2008, 07:06 AM
This is great....
Here is a simple yet useful MEL that I made.....
ControlColor for overriding controller's Color
// Use this tool to help Change the color of the controllers-----------------
//User Interface---------------------
if (`window -exists WCO`) deleteUI WCO;
window
-wh 300 50
-title "Control Colour Overide "
-maximizeButton 0
-rtf true
WCO;
columnLayout -adjustableColumn true ;
global string $color;
$color = `colorIndexSliderGrp -label "Select Color" -min 2 -max 20 -value 10`;
button -label "Change Color" -c "colorMap";
showWindow WCO;
//Procedure for overriding color-------------------
proc colorMap () {
global string $color;
int $colorQuery;
$colorQuery = `colorIndexSliderGrp -q -v $color`;
string $Control[] = `ls -sl`;
string $sel;
for ($sel in $Control){
setAttr ($sel+".overrideEnabled") 1;
setAttr ($sel+".overrideColor") ($colorQuery-1) ;
}}
//The End-----------------------
dagonarth
04-03-2008, 12:34 PM
Hello, I created those two scripts. First one is a simpler version of the center pivot to vertex from, I think, previous page and second is also simpler version of swapnil3d's copy shader script.
They're working really nice but as a newbie to maya scripting (and newbie to programming in anything other than 8bit atari basic ;-) I have one question about 'ls' command. I'm using it for my second script to get the list of the currently selected objects and at the same time to get the list of shaders on that objects.
When I select 'objects' this command gives me list in slection order - selected first is first on that list, second - second etc. But when I'm selecting faces 'ls' command is sorting my selection list and when I was expected to get something like this:
"pPlane1.f[14] pPlane1.f[0] pPlane1.f[4]"
I get the "pPlane1.f[0] pPlane1.f[4] pPlane1.f[14]". Is there any 'not included' in maya commands help switch to turn off the sorting by name? It's a little weird that this isn't sorting the objects by name but leave them in that order in wich you selected them.
Anyway my scripts:
pivot2vertex: choose vertex, execute the script
float $pos[] = `pointPosition`;
if( (`selectPref -q -aa`) == false )
{
selectPref -aa true;
selectMode -o;
xform -ws -piv $pos[0] $pos[1] $pos[2];
selectPref -aa false;
}
else
{
selectMode -o;
xform -ws -piv $pos[0] $pos[1] $pos[2];
}
copyshader: select several objects, execute the script to copy first object shader to other selected objects
string $objname[] = `ls -sl -fl`;
hyperShade -smn "";
string $shdname[] = `ls -sl -fl`;
select $objname;
hyperShade -assign $shdname[0];
EDIT: I just added more functionality to pivot script. Now you can also select whole object, one of its faces or edges. Script will put pivot in centre of selection for example in centre of face, edge or object. Selecting more than 1 faces/edges is also working...
mega.pivot.tool
if( (`selectMode -q -co`) == true )
{
if( (`selectType -q -v`) == true )
{
float $pos[] = `pointPosition`;
if( (`selectPref -q -aa`) == false )
{
selectPref -aa true;
selectMode -o;
xform -ws -piv $pos[0] $pos[1] $pos[2];
selectPref -aa false;
}
else
{
selectMode -o;
xform -ws -piv $pos[0] $pos[1] $pos[2];
}
}
else
{
float $old[3] = `xform -q -ws -piv`;
float $new[6] = `xform -q -ws -bb`;
selectMode -o;
$old[0] = ($new[0] + $new[3]) / 2;
$old[1] = ($new[1] + $new[4]) / 2;
$old[2] = ($new[2] + $new[5]) / 2;
xform -ws -piv $old[0] $old[1] $old[2];
}
}
else CenterPivot;
wajdyf
04-19-2008, 04:59 PM
VISUAL HISTORY
This MEL displays all the steps in creating a model if the history wasn't deleted
I also added a timer to display each step in the modeling procedure.
ENJOY
//*************************************
// Main procedure & User Interface
global proc vHistory()
{
global string $qvhis[];
$qvhis={};
if (`window -q -ex HisWindow` == true) deleteUI HisWindow;
window -w 250 -h 545 -s false -t "visual History v0.8b" -menuBar true HisWindow;
menu -label "Refresh" -allowOptionBoxes false;
menuItem -label "Refresh" -en true -c "vHistory";
scrollLayout scr;
rowColumnLayout -numberOfColumns 2 -columnWidth 1 170
-columnWidth 2 50 ;
global string $selected[];
$selected=`ls -sl`;
if (size($selected) > 0)
{
setAttr ($selected[0]+".v") 1;
global string $hist[];
$hist=`listHistory $selected[0]`;
text -l "";
text -l "";
text -l " The Original";
button -l "Restore" -w 80 -bgc 0.8 0.8 0.9 -c doRestore;
text -l "";
text -l "";
separator;
separator;
text -l "";
text -l "";
text -l " History";
text -l "List";
text -l "";
text -l "";
global string $final;
int $k=0;
for ($h in $hist)
{
string $type=`nodeType $h`;
if ($type != "mesh" && $type != "transformGeometry")
{
text -l (" "+$h);
string $c=("doView(\""+$h+"\")");
button -l "View" -w 80 -c $c;
if ($k==0)
{
$final=$h;
$k=1;
}
}
}
text -l "";
text -l "";
separator;
separator;
text -l "";
text -l "";
text -l " Timer Show";
button -l "Show" -w 80 -bgc 0.8 0.8 0.9 -c doShow;
text -l " Pause in seconds :";
intField -v 1 intf;
text -l "";
text -l "";
separator;
separator;
text -l "";
text -l "";
text -l " Prepare Batch Render";
button -l "Prepare" -w 80 -bgc 0.8 0.8 0.9 -c doBatch;
text -l " Hold step, in frames :";
intField -v 25 iframe;
checkBoxGrp
-numberOfCheckBoxes 1
-label " Don't hide last step" -v1 1 chk;
}
else
text -l "NO OBJECT IS SELECTED";
showWindow HisWindow;
window -e -w 250 -h 545 HisWindow;
}
//*******************************
//********************************
// Batch Prepare :
global proc doBatch()
{
global string $selected[];
global string $hist[];
int $iframe=`intField -q -v iframe`;
int $chk=`checkBoxGrp -q -v1 chk`;
int $sz=size($hist);
int $i=$sz-1;
string $newName;
$j=1;
while ($i >= 0)
{
string $h=$hist[$i];
if (size($h)>0)
{
string $type=`nodeType $h`;
if ($type != "mesh" && $type != "transformGeometry")
{
doView($h);
string $result[];
$result=`duplicate -rr`;
$newName=`rename $result[0] ("step"+$j)`;
if ($j!=1)
{
currentTime (($j-1)*$iframe);
setKeyframe -breakdown 0 -v 0 ($newName+".v");
}
currentTime (($j-1)*$iframe+1);
setKeyframe -breakdown 0 -v 1 ($newName+".v");
currentTime (($j)*$iframe);
setKeyframe -breakdown 0 -v 1 ($newName+".v");
currentTime (($j)*$iframe+1);
setKeyframe -breakdown 0 -v 0 ($newName+".v");
$j++;
}
}
$i--;
}
if ($chk==1)
setKeyframe -breakdown 0 -v 1 ($newName+".v");
currentTime 1;
doRestore();
setAttr ($selected[0]+".v") 0;
}
//************************************
//********************************
// Timer show :
global proc doShow()
{
global string $selected[];
global string $hist[];
int $t=`intField -q -v intf`;
int $sz=size($hist);
int $i=$sz-1;
while ($i >= 0)
{
string $h=$hist[$i];
if (size($h)>0)
{
string $type=`nodeType $h`;
if ($type != "mesh" && $type != "transformGeometry")
{
doView($h);
refresh;
pause -sec $t;
}
}
$i--;
}
doRestore();
}
//************************************
//************************************
//Method 1 (mesh connect)
//Simple , history attribute connection .output or .outputGeometry to the shape's .inMesh
global proc doRestore2()
{
global string $final;
doView($final);
}
global proc doView2(string $s)
{
global string $selected[];
string $rel[]=`listRelatives $selected[0]`;
string $ats[]=`listAttr -c -hd -ro $s`;
for ($at in $ats)
{
string $sub=`substring $at 1 6`;
if ($sub=="output")
{
connectAttr -f ($s+"."+$at) ($rel[0]+".inMesh");
break;
}
}
print ($s+" is shown\n");
}
//************************************
//************************************
//Method 2 (undo)
//General; not only meshs, keeps the original intact , deletes History and undo the delete actions .
global proc doRestore()
{
global string $selected[];
global string $qvhis[];
setAttr ($selected[0]+".v") 1;
if (size($qvhis)>0)
delete $qvhis;
select -r $selected[0];
$qvhis={};
}
global proc doView(string $s)
{
global string $hist[];
global string $selected[];
global string $qvhis[];
setAttr ($selected[0]+".v") 1;
if (size($qvhis)>0)
delete $qvhis;
undoInfo -state on -infinity on;
int $u=0;
for ($h in $hist)
{
if ($h != $s)
{
string $type=`nodeType $h`;
if ($type != "mesh" && $type != "transformGeometry")
{
delete $h;
$u++;
}
}
else
break;
}
undoInfo -swf 0;
$qvhis=`duplicate -rr $selected[0]`;
$qvhis[0]=`rename $qvhis[0] ("history_level_"+$h)`;
setAttr ($selected[0]+".v") 0;
undoInfo -swf 1;
int $i=0;
while ($i<$u)
{
$i++;
undo;
}
select -r $qvhis[0];
}
//************************************
sergioduque
04-23-2008, 03:48 AM
a small script i wrote making it easier to control the render stats for multiple objects without having to do it in the attribute spread sheet.
just save it as a mel file and call it with "multiObjRenderStatsCtrl"
http://sergioduque.tv/renderStats.jpg
global proc multiObjRenderStatsCtrl(){
if (`window -ex myUI`)
deleteUI myUI;
window -t "Render Stats"
-maximizeButton false
-minimizeButton false
-resizeToFitChildren true
myUI;
columnLayout -adjustableColumn 1;
// ===================================chekBoxes
checkBox -v 1 -al left -l " CastShadows " -cc "checkCastSh" castSh;
checkBox -v 1 -al left -l " ReceiveShadows " -cc "checkReceiveSh" receiveSh;
checkBox -v 1 -al left -l " MotionBlur " -cc "checkMotionBlur" mBlur;
checkBox -v 1 -al left -l " PrimaryVisibility " -cc "checkPrimaryVis" primaryVis;
checkBox -v 1 -al left -l " SmoothShading " -cc "checkSmoothShade" smoothShade;
checkBox -v 1 -al left -l " VisibleInReflections " -cc "checkVisReflections" visReflections;
checkBox -v 1 -al left -l " VisibleInRefractions " -cc "checkVisRefractions" visRefractions;
checkBox -v 1 -al left -l " DoubleSided " -cc "checkDoubleSide" doubleSide;
checkBox -v 1 -al left -l " Opposite " -cc "checkOpposite" opposite;
showWindow myUI;
}
// ============================================================= Inicio castShadows
proc checkCastSh(){
string $sel[] = `ls -sl`;
int $primeiro = `checkBox -query -value castSh`;
if ($primeiro == 0){
for ($obj in $sel){
setAttr ($obj + ".castsShadows") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".castsShadows") 1;
}
}
// ============================================================= Fim castShadows
// ============================================================= Inicio receiveShadows
proc checkReceiveSh(){
string $sel[] = `ls -sl`;
int $segundo = `checkBox -query -value receiveSh`;
if ($segundo == 0){
for ($obj in $sel){
setAttr ($obj + ".receiveShadows") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".receiveShadows") 1;
}
}
// ============================================================= Fim receiveShadows
// ============================================================= Inicio motionBlur
proc checkMotionBlur(){
string $sel[] = `ls -sl`;
int $terceiro = `checkBox -query -value mBlur`;
if ($terceiro == 0){
for ($obj in $sel){
setAttr ($obj + ".motionBlur") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".motionBlur") 1;
}
}
// ============================================================= Fim motionBlur
// ============================================================= Inicio primaryVisibility
proc checkPrimaryVis(){
string $sel[] = `ls -sl`;
int $quarto = `checkBox -query -value primaryVis`;
if ($quarto == 0){
for ($obj in $sel){
setAttr ($obj + ".primaryVisibility") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".primaryVisibility") 1;
}
}
// ============================================================= Fim primaryVisibility
// ============================================================= Inicio smoothShading
proc checkSmoothShade(){
string $sel[] = `ls -sl`;
int $quinto = `checkBox -query -value smoothShade`;
if ($quinto == 0){
for ($obj in $sel){
setAttr ($obj + ".smoothShading") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".smoothShading") 1;
}
}
// ============================================================= Fim smoothShading
// ============================================================= Inicio visibleInReflections
proc checkVisReflections(){
string $sel[] = `ls -sl`;
int $sexto = `checkBox -query -value visReflections`;
if ($sexto == 0){
for ($obj in $sel){
setAttr ($obj + ".visibleInReflections") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".visibleInReflections") 1;
}
}
// ============================================================= Fim visibleInReflections
// ============================================================= Inicio visibleInRefractions
proc checkVisRefractions(){
string $sel[] = `ls -sl`;
int $setimo = `checkBox -query -value visRefractions`;
if ($setimo == 0){
for ($obj in $sel){
setAttr ($obj + ".visibleInRefractions") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".visibleInRefractions") 1;
}
}
// ============================================================= Fim visibleInRefractions
// ============================================================= Inicio doubleSided
proc checkDoubleSide(){
string $sel[] = `ls -sl`;
int $oitavo = `checkBox -query -value doubleSide`;
if ($oitavo == 0){
for ($obj in $sel){
setAttr ($obj + ".doubleSided") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".doubleSided") 1;
}
}
// ============================================================= Fim doubleSided
// ============================================================= Inicio opposite
proc checkOpposite(){
string $sel[] = `ls -sl`;
int $nono = `checkBox -query -value opposite`;
if ($nono == 0){
for ($obj in $sel){
setAttr ($obj + ".opposite") 0;
}
}
else
for ($obj in $sel){
setAttr ($obj + ".opposite") 1;
}
}
// ============================================================= Fim opposite
-sergio
ewerybody
04-24-2008, 07:57 AM
wow! I just discovered this thread!! :D
Its from 2002 and still not dead ^^ cool thang
ok want some snippets stuff from my shelf? :
//open folder containing the scene:
system ("explorer /select,\"" + toNativePath(`file -q -location`) + "\"");
// match position:
{
string $sel[] = `ls -sl -tr`;
if (size($sel) > 1)
{
float $pos[] = `xform -q -t -ws $sel[0]`;
float $rot[] = `xform -q -ro -ws $sel[0]`;
float $scl[] = getAttr ($sel[0] + ".scale");
$sel = stringArrayRemove({$sel[0]},$sel);
for ($obj in $sel)
{
setAttr ($obj + ".translate") $pos[0] $pos[1] $pos[2];
setAttr ($obj + ".rotate") $rot[0] $rot[1] $rot[2];
setAttr ($obj + ".scale") $scl[0] $scl[1] $scl[2];
}
}
}
// match pivot
// match pivot
{
string $sel[] = `ls -sl -tr`;
if (size($sel) > 1)
{
float $pPos[] = `xform -q -ws -rotatePivot $sel[0]`;
$sel = stringArrayRemove({$sel[0]},$sel);
for ($obj in $sel)
move -a $pPos[0] $pPos[1] $pPos[2] ($obj + ".scalePivot") ($obj + ".rotatePivot");
}
}
// context sensitive delete history
if (size(`ls -sl`))
delete -ch;
else
{
delete -all -ch;
warning "whole construction history deleted !";
}
you know you can select a code-snippet and drag it directly onto the shelf!!
Ashram
05-30-2008, 03:29 AM
This is a MEL script to generate a patch of grass which I learnt in my class.
proc string generateBlade(string $levelOfDetail, string $style)
// change grass to blade and make local
{
// Declaration of variables
float $grassRadius = `rand 0.02 0.06`;
float $grassHeight;
float $grassCurl;
float $envelopeVal;
// Declaration of variable for subdivisionsY
float $value;
// Change height and bend values to accommodate user input.
switch($style)
{
case "short":
{
$grassHeight = `rand 0.4 0.8`;
$grassCurl = `rand 0 -.1`;
$envelopeVal = `rand 0.9 1.0`;
switch($levelOfDetail)
{
case "low":
$value = 1;
break;
case "medium":
$value = 3;
break;
case "high":
$value = 5;
break;
}
}
break;
case "normal":
{
$grassHeight = `rand 0.7 1.2`;
$grassCurl = `rand -0.25 -1.0`;
$envelopeVal = `rand 0.6 1.0`;
switch($levelOfDetail)
{
case "low":
$value = 3;
break;
case "medium":
$value = 5;
break;
case "high":
$value = 10;
break;
}
}
break;
case "long":
{
$grassHeight = `rand 1 1.6`;
$grassCurl = `rand -0.35 -1.25`;
$envelopeVal = `rand 0.5 1.0`;
switch($levelOfDetail)
{
case "low":
$value = 4;
break;
case "medium":
$value = 7;
break;
case "high":
$value = 11;
break;
}
}
break;
case "very long":
{
$grassHeight = `rand 2 3.5`;
$grassCurl = `rand -1 -1.5`;
$envelopeVal = `rand 0.5 0.85`;
switch($levelOfDetail)
{
case "low":
$value = 5;
break;
case "medium":
$value = 8;
break;
case "high":
$value = 13;
break;
}
}
break;
default:
{
warning ("Type " + $style + " is unknown. Using default settings.");
$grassHeight = `rand 0.7 1.2`;
$grassCurl = `rand -0.25 -1`;
$envelopeVal = `rand 0.6 1.0`;
switch($levelOfDetail)
{
case "low":
$value = 3;
break;
case "medium":
$value = 6;
break;
case "high":
$value = 10;
break;
}
}
break;
}
//Creation of Poly Cone
string $blades[] = `polyCone
-radius $grassRadius
-height $grassHeight
-subdivisionsX 3
-subdivisionsY $value
-subdivisionsZ 0
-axis 0 1 0
-texture 1
-constructionHistory off`;
// Bring the bottom of the cone to ground level
setAttr ($blades[0] + ".translateY") ($grassHeight* 0.5);
// harden the edges of cone
polySoftEdge
-angle 30
($blades[0] + ".e[0:59]")
;
// this can be done in the Maya interface with the cone selected and
// selecting Normals>Harden Edge
// The ".e[#:#] refers to the edge numbers ranging from 0 to 59
// go back to object mode
// and ensure the cone is selected
changeSelectMode -object;
select -replace $blades;
// make the blade thin;
setAttr ($blades[0] + ".scaleX") 0.25;
makeIdentity
-apply true
-translate true
-rotate true
-scale true
$blades[0];
makeIdentity
-apply false
-translate true
-rotate true
-scale true
$blades[0];
// Add the bend deformer, capture the name to move it
string $bend[] = `nonLinear
-type bend
-lowBound 0
-highBound 2
-curvature $grassCurl`
;
//$bend[1] stores the deformer's transformation info
//$bend[0] stores the deformer's deformation parameters
setAttr($bend[1] + ".ty") 0;
setAttr($bend[0] + ".envelope") $envelopeVal;
select -replace $blades;
delete -constructionHistory $blades;
return $blades[0];
// this will return the geometry's transform node of the cone created.
}
global proc generateGrass(string $levelOfDetail, string $style, int $density)
{
// Declare variables
string $createdGrass[];
//for loop to create multiple blades of grass
for($i=0;$i<$density;$i++)
{
$createdGrass[`size $createdGrass`] = `generateBlade $levelOfDetail $style`;
// Generate Random Values for translation and rotation
float $randomX = `rand -5 5`;
float $randomZ = `rand -5 5`;
float $randomRotate = `rand 0 360`;
// Assign the random values to the translate values
setAttr ($createdGrass[$i] + ".translateX") $randomX;
setAttr ($createdGrass[$i] + ".translateZ") $randomZ;
setAttr ($createdGrass[$i] + ".rotateY") $randomRotate;
if(`size $createdGrass` > 500)
{
string $united[] = `polyUnite $createdGrass`;
clear $createdGrass;
$createdGrass = $united;
flushUndo;
}
} // end of for loop
polyUnite -constructionHistory off $createdGrass;
// do a final combine
// select the created geometry
select -replace $createdGrass;
}
generateGrass low long 500;
TheNeverman
06-04-2008, 04:45 PM
pretty slick script Ashram,
can you tell me what the 'style 500' attribute controls? What is the acceptable value range?
the script also throws up an error on line 382:
"No object matches name: pCone1"
jschieck
06-19-2008, 02:55 AM
Hey guys!
Here's my first "finished" script. Made it for a friend who doesn't like modeling at school because he doesn't have room for his reference images without dual monitors.
This creates a nice window allowing you to load in images which creates small thumbnails, then by clicking them it will load them larger below allowing you to zoom in on them and pan around. Also allows you to save out reference sets and load them back in later, as long as the reference image locations havn't changed. You can also delete unwanted thumbnails.
The code is super clunky I know but it works. I started out thinking it would be super quick and ended up adding more stuff to it as I went. :shrug:
http://www.jacobschieck.com/wp/files/priv/ref_win.jpghttp://jacobschieck.com/files/priv/ref_win.jpg
REFERENCE WINDOW SCRIPT
http://www.jacobschieck.com/files/js_refWindow.mel (http://www.jacobschieck.com/files/js_refWindow.mel)(right click -> save as...)
Hope this is useful to somebody. Enjoy!
leif3d
06-20-2008, 07:50 PM
Hi guys,
I'm doing a project work & i need a mel script for dual resolution gate like i need both HD 1080 & PAL 768 shown at the same time. Here is an example in this image
http://img186.imageshack.us/img186/415/rg1cc0.jpg
With that red mark being a PAL 768 (768x576) standard. Can anyone please tell me the script for this, please.
This would very helpful! Is there a way to do this already in Maya? it just seems like something that someone has to have thought about earlier...
ewerybody
09-12-2008, 09:47 AM
a little hackky but ... maybe try:
proc string getStringArrayItem0(string $array[])
{
return $array[0];
}
{
$camChildren = `listRelatives -c -type "transform" persp`;
if (size($camChildren))
delete $camChildren;
string $curve1 = `curve -d 1 -p 0 0 -0.5 -p 0 0 0.5 -k 0 -k 1`;
string $curve2 = `curve -d 1 -p 0 0 -0.5 -p 0 0 0.5 -k 0 -k 1`;
$curve1 = getStringArrayItem0(`parent $curve1 persp`);
$curve2 = getStringArrayItem0(`parent $curve2 persp`);
setAttr ($curve1 + ".t") 0.5 0 -1.3;
setAttr ($curve2 + ".t") -0.5 0 -1.3;
setAttr ($curve1 + ".r") 90 0 0;
setAttr ($curve2 + ".r") 90 0 -180;
setAttr ($curve1 + ".overrideEnabled") 1;
setAttr ($curve1 + ".overrideDisplayType") 2;
setAttr ($curve2 + ".overrideEnabled") 1;
setAttr ($curve2 + ".overrideDisplayType") 2;
select $curve1 $curve2;
manipMoveContext -edit -mode 0 Move;
}
then you can drag the x-axis to your desired position.
with a little math and connections you may do this more properly concerning the real resolutions and stuff ... but I'm to lazy to find out for you :D
http://img145.imageshack.us/img145/7295/aashots038or1.jpg
cgbeige
01-02-2009, 05:28 PM
Are you still looking for script :)
http://denisg.com/images/dgRandomiser.jpg
link - http://denisg.com/downloads/dgRandomiser.rar
thanks for this and dgCopyKeys but they both are cut off at the bottom on OS X (Maya 2009). Thought you'd want to know.
tinytimw52
01-23-2009, 12:55 AM
I never used mel before, but I just tried making that box made out of curves. pretty cool stuff.
mahagnosis
01-29-2009, 07:32 PM
hi Guys,
I'm very new in this MEL Script, and not quite sure about it's function (other than Maya GUI's manipulation and animation).
Can MEL Script actually create an executable data?
thanks
ewerybody
01-29-2009, 10:17 PM
what MEL script? you mean new in MEL scripting at all?! :)
With MEL you can do almost anything inside Maya. Maya is actually a collection of programmed parts that are all plugged together via MEL. Everything you look at in Mayas interface is somehow MEL scripted.
On the other Hand MEL is quite worthless outside of Maya. But actually if you manage MEL you can script any language :D
mahagnosis
01-30-2009, 08:39 AM
I see :)
thanks for the explaining.
i was thinking to make an animated application ^^;
Diegoheavens
02-06-2009, 07:45 PM
I have a script which applies an NiMultishader to the selected object, creates an Occlusion color set in the CSE, occludes the mesh with all correct presets, and have a window which allows you to rebake with sliders to change the settings or modify the current bake set. But, I'm having trouble with what sounds like the most simplest step, selecting colorSet1 and the Occlusion color set and blend them both into a new blendedBakeSet using an "Add" polyColorBlendMode.
Here is my script
If anyone could help that person is amazing
------------------------------------------------------------------------------------
// Create Warning Prompt
global proc checkboxPrompt(){
// Dialog Form window.
//
string $form = `setParent -q`;
// Layout Dialog Box
formLayout -e -width 300 -height 300 $form;
string $t = `text -l "DO NOT PRESS CTRL Z OR Z After Script, close this box"`;
}
layoutDialog -ui "checkboxPrompt";
{
//place objects selected into a variable
$jrdSel=`ls -sl`;
//Delete History, Freeze Transforms, Center Pivot to World
DeleteHistory;
delete -ch;
FreezeTransformations;
performFreezeTransformations(0);
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
EnterEditMode;
ctxEditMode;
SnapToPoint;
snapMode -point (!`snapMode -q -point`);
updateSnapMasks;
move 0 0 0 $jrdSel.scalePivot $jrdSel.rotatePivot ;
SnapToPoint;
// Create Occlusion Bake Set with presets
{
$bakeSetAO=`createBakeSet OcclusionSet vertexBakeSet`;
setAttr OcclusionSet.colorMode 3;
setAttr OcclusionSet.occlusionRays 256;
setAttr OcclusionSet.occlusionFalloff 100;
setAttr OcclusionSet.normalDirection 1;
setAttr OcclusionSet.orthogonalReflection 1;
setAttr OcclusionSet.bakeColor 1;
setAttr OcclusionSet.bakeAlpha 0;
setAttr -type "string" OcclusionSet.colorSetName "Occlusion";
}
// Creates Bake Set
if ( `objExists initialTextureBakeSet` == 0 )
{
createBakeSet initialTextureBakeSet textureBakeSet;
}
if ( `objExists initialVertexBakeSet` == 0 )
{
createBakeSet initialVertexBakeSet vertexBakeSet;
}
// Assign the shape nodes to Occlusion
for ( $eachObj in $jrdSel )
{
string $shape[]=`listRelatives -s $eachObj`;
sets -forceElement OcclusionSet $shape[0];
}
// Bake selected Objects.
select -r $jrdSel;
catchQuiet ( `convertLightmapSetup -camera persp -sh -vm -showcpv` );
}
{
$jrdSel=`ls -sl`;
// Assign a NiMultiShader to a combined mesh .
//
string $myShader = `shadingNode -asShader NiMultiShader`;
string $NiMultiShader1SG = ($myShader + "NiMultiShader1SG");
sets -renderable true -noSurfaceShader true
-empty -name $NiMultiShader1SG;
defaultNavigation -connectToExisting
-source $myShader
-destination $NiMultiShader1SG;
select -r $jrdSel;
sets -e -forceElement $NiMultiShader1SG;
{
$jrdSel=`ls -sl`;
if (`window -exists myWindow`) { deleteUI -window myWindow; }
window -rtf true -title "OcclusionReBake" myWindow;
columnLayout;
floatSliderGrp -dragCommand "findValues" -minValue 0 -maxValue 4 -label "Color Mode" -field true posCol;
floatSliderGrp -dragCommand "findValues" -minValue 1 -maxValue 256 -label "Occlusion Rays" -field true posRay;
floatSliderGrp -dragCommand "findValues" -minValue 0 -maxValue 100 -label "Occlusion Falloff" -field true posFal;
columnLayout -adjustableColumn true;
button -label "Bake" -c BatchBake;
button -label "Color Set Editor" -c "colorSetEditor";
button -h 26 -w 80 -l "Modify Bake"
-c "colorSetEditCmd modify colorSetList"
-enable true
modifyButton;
showWindow myWindow;
proc findValues () {
float $myNumPosCol = `floatSliderGrp -q -value "posCol"`;
float $myNumPosRay = `floatSliderGrp -q -value "posRay"`;
float $myNumPosFal = `floatSliderGrp -q -value "posFal"`;
print $myNumPosFal;
setAttr "OcclusionSet.colorMode" $myNumPosCol;
setAttr "OcclusionSet.occlusionRays" $myNumPosRay;
setAttr "OcclusionSet.occlusionFalloff" $myNumPosFal;
select -r $jrdSel;
}
HypershadeWindow;
colorSetEditor;
}
}
Cayla
04-14-2009, 03:18 PM
Hi
I need to know if it is possible to connect MAYA with C#... I know it is a weird question but my boss is having a go at me cause I really do not know.....
I think the answer is NO but still need to hear it from someone that has been doing this for longer than me...
If anyone can help please let me know.
Thanks.
ewerybody
04-15-2009, 07:26 AM
google is your friend:
http://www.google.com/search?&q=maya%20plugins%20with%20c%23
why posting this in "MEL scripts"?!?!? :surprised
Cayla
04-15-2009, 07:39 AM
Because I need to know if it is possible to integrate mel and C#.
ewerybody
04-15-2009, 10:10 AM
Yea but for more than 6 years over 20 pages people in this thread discuss certain Mel Scripts.
I mean open up a new thread in the parent thread "Maya Programming" thats what its for! :D
btw: for "mel" I can tell you: yes its pretty possible to do stuff with it in Maya ;]
But for C#: yea see the search there are guys talking about it. should work.
Cayla
04-15-2009, 11:10 AM
Thanks for the advice
divanovic
04-21-2009, 09:13 AM
Hi,
thanks for this great thread!
I have some MEL scripts that I used on my projects. They are now cleaned up and uploaded on my site, under downloads section, so you can freely use them.
www.deform.rs
1. Change render stats on multiple objects, included with a layering override.
2. Toggle Lock/Hide on transform channel quickly and easily
3. Duplicate objects along a particle shape, useful for environment trees etc...
I guess there are a lot of similar tools around the net, but I prefer writing my own tools when facing a problem, so that is how I got to these.
All of the scripts have a UI for easier use, and the info about installation/starting is included in the script file.
I hope you will have some benefit from them, regards to all and keep it up!!
Dejan Ivanovic
sico11
05-20-2009, 06:41 AM
hello, i want to make some objects floating in space and i dont know how can i do this. so can anyone help me making an object move free on the 3 axis very slow. i want to do this because i want to control the distances between the object is moving and the speed also.
thanks.
ewerybody
05-20-2009, 06:52 AM
if you don't have a mel script for this thread, why don't you open a new thread for your question?
sico11
05-20-2009, 06:58 AM
sry:( ill do that right away.
sico11
05-20-2009, 08:24 AM
sry:( my mistake
ewerybody
05-20-2009, 09:48 AM
did't post a script as well :/
but I might have something:
// hides the menubars on the panels under the cursor
// on the modelpanel 4 is also shows/hides the darn icon bar
{
$thisPanel = `getPanel -wf`;
$menuBarvis= `panel -q -menuBarVisible $thisPanel`;
if ($thisPanel == "modelPanel4")
{
if ($menuBarvis)
layout -e -visible false -height 1 formLayout72;
else
layout -e -visible true -height 20 formLayout72;
}
panel -e -menuBarVisible (!$menuBarvis) $thisPanel;
}
I'm always longing for ways to get more space in Maya.. :]
Great thread !
I don't actually have an MEL to share because i am a newb at this LOL !!
Simple spiral creator. Very basic. I'm still learning. I did this mainly to help understand UI construction better.
safakoner
07-09-2009, 04:47 PM
global proc OptionMenu_RemoveItems(string $optionMenu)
{
int $itemsCount = `optionMenu -q -ni $optionMenu`;
if($itemsCount == 0)
{
//do error handling
}
else
{
int $i;
for($i=$itemsCount; $i>0; $i--)
{
optionMenu -e -sl $i $optionMenu;
string $menuItem = (`optionMenu -q -v $optionMenu` + "_" + $optionMenu);
deleteUI $menuItem;
}
}
}
global proc OptionMenu_AddItems(string $items[], string $optionMenu)
{
int $itemsCount = `size $items`;
if($itemsCount == 0)
{
//do error handling
}
else
{
int $i;
for($i=0; $i<$itemsCount; $i++)
{
menuItem -l $items[$i] -p ($optionMenu) -ann "" ($items[$i] + "_" + $optionMenu);
}
}
}
Boucha
07-15-2009, 01:50 AM
Here is a little MEL script that I wrote for easily creating a deformable ribbon setup. User have the ability to change the length, width, number of joints (UV Span)...
Click here for the link... (http://www.highend3d.com/maya/downloads/mel_scripts/animation/srbRibbon-5869.html)
Enjoy !
johneyrussia
09-12-2009, 06:22 AM
Hello All
I,m feeling confuse about Arrays.I know that arrays are 0 based & it's first element is 0,second 1 & so on. But there is a one command in maya called stringArrayRemove.It requires two arrays.One Syntax is Confusing me.Actually,I write that: string $allCameras[] = `listCameras`;
// Result: top,pers,front,side //
string $removeThis[1] = {"pers"};
// Result: pers //
string $result[] = stringArrayRemove ($removeThis, $allCameras[]);
// Result: top,front,side //
This Syntax is confusing me : string $removeThis[1] = {"pers"};
I've understood everything,but when I declare 0 or 2 or 3 or another number in [1] ,then it works same,if I don't declare nothing in [ ] , then the result is same.So why we declare 1 in [ ].I know that "stringArrayRemove" wants two Array.But without declaring or declaring another value in [ ] it works same.Specially,I felt more confusion when I declare number 0 like this [ 0 ] it's meaning that it holds one Item,not Two (according to me).then it work same like declaring [ 1 ]. But Command called "stringArrayRemove" wants two Arrays,then why [ 0 ] works same.
What's the Reasion Behind this : string $removeThis[1] = {"pers"};
PLEASE HELP ME!
Thanks & Warm Regards
Rajat Chauhan
ewerybody
09-12-2009, 12:12 PM
you can declare the lenght of the array in the []. So if you know that your array will have 3 elements like for a translation for instance you may declare it: float $pos[3]. MEL will automatically extend the array if you stuff more into it. But this way you can safe memory and processing time.
Of course if you don't do thousands of loops you can trustfully ignore this feature. But IF you do and you have like hundreds of entries MEL has to extend the array over and over again which can cost valuable time.
this:
string $result[] = stringArrayRemove ($removeThis, $allCameras[]);
actually shouldn't work because of the empty [] ^, huh?
and you can also have this inline:
string $allCameras[] = stringArrayRemove({"persp"},`listCameras`);
and pls: next time just open a new thread for problems like this. This one is supposed to have mel scripts posted into it. Which I have to admit I'm lacking this time as well. Mea culpa. next time.:shrug:
johneyrussia
09-12-2009, 05:13 PM
Thanks Very Much !
isoparmB
09-13-2009, 12:02 AM
Interesting thread.
Here's a little widget I use for rigging. Creates a locator at center of the bounding box of selected objects. Great for laying out guide locators when rigging. For example, just select the edge loop or vertices for an elbow to get the optimal position for elbow joints, etc.
global proc refLoc()
{
float $bBox[] = `exactWorldBoundingBox`;
float $coordinateX = $bBox[0] - (($bBox[0] - $bBox[3]) * .5);
float $coordinateY = $bBox[1] - (($bBox[1] - $bBox[4]) * .5);
float $coordinateZ = $bBox[2] - (($bBox[2] - $bBox[5]) * .5);
spaceLocator -p $coordinateX $coordinateY $coordinateZ;
CenterPivot;
};
refLoc;
johneyrussia
09-13-2009, 03:07 AM
It's Great !
ruchitinfushion
10-03-2009, 03:09 PM
Hello,ppl plz help me here.i have one sphere at (0,0,0) now i want to move my sphere in clock wise and anticlockwise with the radius of 3 unit.plz i want to learn how to do this using expression, no with the manual like motion path and etc.
and if i get control over speed also then is will bonus for me.Thank you.
ruchitinfushion
10-04-2009, 04:59 AM
hello reply plz,how to move sphere in clockwise & anti clock wise with give radius.using expression
phix314
10-08-2009, 06:38 PM
Tweak script:
Takes the selection of objects and applies random adjustments to the rotate, translate, or scale. This is the first version, so it could use some optimizing I'm sure, but it works :)
proc tweak(string $direction, float $maxAmount, string $ctx){
string $eachDir[];
string $eachCtx[];
float $rand;
string $sel[] = `ls -sl`;
$eachDir = stringToStringArray($direction, ",");
$eachCtx = stringToStringArray(tolower($ctx), ",");
if(0 == size($eachCtx)){
$rand = rand($maxAmount * -1, $maxAmount);
for($object in $sel){
print("Setting the one attr:" + $ctx + "\n");
}
}else{
string $attr;
for($object in $sel){
$rand = rand($maxAmount * -1, $maxAmount);
for($direction in $eachDir){
for($cx in $eachCtx){
//print("Must move " + $object + " attribute '" + $cx + "' in the " + $direction + "\n");
switch($cx){
case "t":
$attr = "translate";
break;
case "r":
$attr = "rotate";
break;
case "s":
$attr = "scale";
break;
}
//setAttr object.attributeX amount
setAttr($object + "." + $attr + $direction) $rand;
}
}
}
}
}
tweak("X,Y,Z", 10, "r,s");
There's been a few times building walls or something similar where I just needed a hint of variety.
jaydru
11-16-2009, 03:52 PM
i thought id share this that i wrote last night, converts an edge loop to nurbs curve, wont work if the edge loop crosses over it self
/*------------------------------*\
creates a 3 degree nurbs curve
along the selected edge loop
note: will not work if loop
crosses over it's self
by james drew
\*------------------------------*/
global proc edgeLoopToWire(){
$edges = `ls -sl -fl`;
string $verts[];
vector $xyz[];
string $sortedVerts[];
for ($edge in $edges)
{
$verts[size($verts)] = stringArrayToString(filterExpand("-ex", 1, "-sm", 31, polyListComponentConversion("-tv", $edge)), " ");
}
//now to sort
string $sortedVerts[] = stringToStringArray($verts[0], " ");
stringArrayRemoveAtIndex(0, $verts);
string $vertBuffer[] = $verts;
for ($each in $verts)
{
for ($vert in $vertBuffer)
{
$vtxs = stringToStringArray($vert, " ");
if ($vtxs[0] == $sortedVerts[size($sortedVerts) -1])
{
$sortedVerts[size($sortedVerts)] = $vtxs[1];
$vertBuffer = stringArrayRemoveExact(stringToStringArray($vert, ""), $vertBuffer);
break;
}
else if ($vtxs[1] == $sortedVerts[size($sortedVerts) -1])
{
$sortedVerts[size($sortedVerts)] = $vtxs[0];
$vertBuffer = stringArrayRemoveExact(stringToStringArray($vert, ""), $vertBuffer);
break;
}
else if ($vtxs[0] == $sortedVerts[0])
{
stringArrayInsertAtIndex(0, $sortedVerts, $vtxs[1]);
$vertBuffer = stringArrayRemoveExact(stringToStringArray($vert, ""), $vertBuffer);
break;
}
else if ($vtxs[1] == $sortedVerts[0])
{
stringArrayInsertAtIndex(0, $sortedVerts, $vtxs[0]);
$vertBuffer = stringArrayRemoveExact(stringToStringArray($vert, ""), $vertBuffer);
break;
}
}
}
//verts are now sorted
string $createCurve = "curve -d 3 ";
for ($vert in $sortedVerts)
{
$pnt = pointPosition($vert);
$createCurve = ($createCurve + "-p " + $pnt[0] + " " + $pnt[1] + " " + $pnt[2] + " ");
}
$curve = `eval $createCurve`;
//if curve is a loop sealit it up
if ($sortedVerts[0] == $sortedVerts[size($sortedVerts)-1])
closeCurve -ch 0 -ps 2 -rpo 1 -bb 0.5 -bki 1 -p 0.1 $curve;
select $curve;
}
phix314
11-18-2009, 07:03 AM
Connects a bokeh node with distance and parents one locator to the camera.
global proc bokeh(){
string $sel[] = `ls -sl`;
float $childPos[] = `xform -q -t $sel[0]`;
float $camPos[] = `xform -q -t $sel[1]`;
string $cShape[] = `listRelatives -s $sel[1]`;
string $bokehNode = ($sel[1]+"_bokeh");
string $ddShape = ($cShape[0]+"_ddm");
string $dd = `distanceDimension -sp $childPos[0] $childPos[1] $childPos[2] -ep $camPos[0]
$camPos[1] $camPos[2]`;
rename $dd $ddShape;
string $con[] = `listConnections $ddShape`;
parent $con[1] $sel[1];
string $bokeh = `mrCreateCustomNode -asUtility "" mia_lens_bokeh`;
rename $bokeh $bokehNode;
connectAttr -f ($bokehNode+".message") ($cShape[0]+".miLensShader");
connectAttr -f ($ddShape+".distance") ($bokehNode+".plane");
}
bokeh();
phix314
11-20-2009, 06:49 AM
Not sure how many people are going to use something like this, but I thought I'd share just in case.
Considering the network for the mip_ shaders (in this case for compositing) is ridiculous, this helps it along. This network is based on what's seen here:
http://forums.cgsociety.org/showthread.php?f=87&t=541718&page=2&pp=15&highlight=mip_cameramap
Select camera and run.
global proc setMipBG(){
string $sel[] = `ls -sl`;
string $selShapes[] = `listRelatives -f $sel[0]`;
string $camPath = $selShapes[0];
// GLOBAL NODES //
string $emptyAlpha = `mrCreateCustomNode -asUtility "" mib_color_alpha`;
setAttr ($emptyAlpha+".factor") 0;
// CAMERA NODES //
string $cEnv = `mrCreateCustomNode -asUtility "" mip_rayswitch_environment`;
string $cHdr = `mrCreateCustomNode -asUtility "" mip_mirrorball`;
setAttr ($cHdr+".degamma") 2.2;
// MATERIAL NODES //
string $mEnv = `mrCreateCustomNode -asUtility "" mip_rayswitch_environment`;
string $mCmap = `mrCreateCustomNode -asUtility "" mip_cameramap`;
setAttr ($mCmap+".degamma") 2.2;
string $ms = `mrCreateCustomNode -asShader "" mip_matteshadow`;
// CAMERA CONNECTIONS //
connectAttr -f ($cEnv+".message") ($camPath+".miEnvironmentShader");
connectAttr -f ($emptyAlpha+".outValue") ($cEnv+".background");
connectAttr -f ($emptyAlpha+".outValueA") ($cEnv+".backgroundA");
connectAttr -f ($cHdr+".outValue") ($cEnv+".environment");
connectAttr -f ($cHdr+".outValueA") ($cEnv+".environmentA");
// MATERIAL CONNECTIONS //
connectAttr($emptyAlpha+".outValue") ($mEnv+".background");
connectAttr($emptyAlpha+".outValueA") ($mEnv+".backgroundA");
connectAttr($mCmap+".outValue") ($mEnv+".environment");
connectAttr($mCmap+".outValueA") ($mEnv+".environmentA");
connectAttr ($mEnv+".outValue") ($ms+".background");
connectAttr ($mEnv+".outValueA") ($ms+".backgroundA");
}
Feel free to tear it up, but for me I run this script when I'm ready to start the rendering-for-compositing home stretch. Gets the nodes connected up (sans textures/shading groups) and I can apply it to different cameras/export with ease.
Camaro
01-11-2010, 10:51 PM
Hi folks, I'm new here, just thought I'd post a neat little script to change the value of a checkbox according to whether or not it was checked before (i.e. in a window that was later closed)
window testWindow;
columnLayout;
checkBox
-onCommand $onValue
-offCommand $offValue
-value $testValue
testBox;
showWindow testWindow;
int $testValue = `checkBox -q -v testBox`;
string $onValue = "$testValue = 1";
string $offValue = "$testValue = 0";
It's nothing special but I think it's pretty cool :thumbsup:
ewerybody
01-12-2010, 09:36 AM
Hi Camaro!
If you thought thats cool. Check this out:
you can have that with an optionVar much cleaner and straightforward!
window;
columnLayout;
checkBox
-v (`optionVar -q myTextCheckBoxOptionVar`)
-cc ("optionVar -iv myTextCheckBoxOptionVar #1");
showWindow;
plus: with the secret #1 placeholder you automatically put in the current value of the control. Works with almost all controls :thumbsup:
Camaro
01-12-2010, 02:41 PM
Hey thanks, I'll have to test that out! :bowdown:
Camaro
01-12-2010, 11:09 PM
Ok, I have to say, I went through the command reference, and I don't understand it one bit. Could someone explain how to use optionVar in detail?
ewerybody
01-13-2010, 11:53 AM
He Camaro!
optionVar (http://download.autodesk.com/us/maya/2009help/Commands/optionVar.html) is the one command Maya uses itself to save all the preferences. And you can utilize it yourself very easily! Its clean, fast and the best: persistent!
Even if the optionVar-name does not existoptionVar -q "yourOptionVarName";returns a proper integer 0.
So you can use it in your checkBox and create/toggle the optionVar on -changeCommand with:
optionVar -intValue "yourOptionVarName" $yourIntValue;for instance.
in the same style you can have floats and strings saved as well.
What else is unclear?
Camaro
01-13-2010, 06:15 PM
So you use the -intValue flag when its a 1 or 0 like a checkbox?
ewerybody
01-14-2010, 09:38 AM
exactly.
The -value flag awaits an integer. So you can feed it with anything that returns one.checkBox -v 1;
checkBox -v $myIntVar;
checkBox -v ((int) $aFloatVariable);
checkBox -v (`optionVar -q myTextCheckBoxOptionVar`);IF "myTextCheckBoxOptionVar" is defined as an -intValue optionVar of course...
Camaro
01-15-2010, 02:35 AM
Any reason MEL can't interpret a decimal value, such as (35 / 100)? This could screw up my whole script if I can't get something simple like that to work. All I need is a decimal/float value.
My only other alternative is to take a value like 35 and convert it to .35 somehow.
isoparmB
01-15-2010, 04:06 AM
Try:
float $result = (35.0 / 100.0)
ewerybody
01-15-2010, 11:06 AM
or in a call you can always cast variables to a certain type like I wrote in the example: ((int) $floatVar) or ((float) $intVar1 / $intVar2)
Camaro
01-18-2010, 12:32 AM
Is there any way to make it so you can specify the shape of a button other than a square/box? Or perhaps use an image as a button somehow (not a symbolButton, mind you)?
I'm trying to emulate this:
http://www.paolodominici.com/products/zvgui/#media
But obviously not as advanced, as I'm pretty sure he uses Python. I'm just trying to make it so the user can select parts of a rig from an image without simple boxes for the buttons.
Sorry for turning this into a question thread, I just don't want to clog up the main forum with a bunch of different threads/questions.
jschieck
01-18-2010, 12:59 AM
the command iconTextButton should work for you, it'll still be square but you can use an image instead.
u can also make the image your using transparent by making the background of your .bmp 0 254 0 rgb colors and indexing it to the first slot in your color index.
ewerybody
01-18-2010, 09:27 AM
Is there any way to make it so you can specify the shape of a button other than a square/box? Or perhaps use an image as a button somehow (not a symbolButton, mind you)?The functional shape of Mayas buttons will always be rectangular. Maybe you go pyQT? Don't know of its capability now but should be huge ^^
I'm trying to emulate this:
http://www.paolodominici.com/products/zvgui/#mediaAt least you can have mouseover-images utilising the shelfButton images.
Sorry for turning this into a question thread, I just don't want to clog up the main forum with a bunch of different threads/questions.Thats exactly what its there for!! :]
ewerybody
01-19-2010, 09:36 AM
sorry for helping to move this thread out of track. Some more helpful little melScripts:
I often animate lots of nodes. This simply copys the animation of 1 object to all other selected ones, no selection order to care about:
{
string $sel[] = `ls -sl`;
// get animcurves from selection and route back to animated transforms
string $animated[] = stringArrayRemoveDuplicates(listConnections(`keyframe -q -name`));
if (!size($animated))
error"no animated obj!";
if (size($animated) > 1)
error"can only copy from 1 animated obj!";
// so if there is only 1 animated obj we can go on:
// remove the animated one from the selection array
$sel = stringArrayRemove($animated,$sel);
// copy from anmated, paste on all others:
copyKey $animated[0];
pasteKey $sel;
}
ranjeetthecgartist
01-26-2010, 09:19 AM
actually i want to know abt autosuspension ,means i want to do suspension in my car.in scene my car is passing through hilly area,so the road has many up , downs & i dont want to creat suspension manually.i i want to do it through expression,is there any way to do my work throuh expression or script.plz help me.i m creating my demo real.
ewerybody
01-26-2010, 10:09 AM
Hi ranjeetthecgartist!
What about posting your question in a new topic in the main thread (http://forums.cgsociety.org/forumdisplay.php?f=89)?
This here is about posting/sharing and discussing existing scripts.
Diancoff
01-28-2010, 04:47 PM
I made a little time saver for those cases that you want a reflection to appear at a specific place on your object. (see the screenshot and the render)
This script creates two straight lines, grouped together. You position the main one (the one with less expressions on it) pointing to the camera and the tip of the two lines should be on the surface.
http://img36.imageshack.us/img36/2295/reflectionsguide.jpg (http://img36.imageshack.us/i/reflectionsguide.jpg/)
EPCurveTool;
curve -d 3 -p 0.00509434 0 0.251053 -p 0.333085 0 0.256715 -p 0.661075 0 0.262377 -p 0.989066 0 0.268039 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1 ;
select -r curve1.cv[0] ;
move 0 0 0 ;
select -r curve1.cv[3] ;
move 6 0 0 ;
select -r curve1.cv[2] ;
move 4 0 0 ;
select -r curve1.cv[1] ;
move 2 0 0 ;
select -cl ;
select -r curve1.cv[0:3] ;
hilite curve1.cv[0:3] ;
select -d curve1.cv[0:3] ;
hilite -u curve1 ;
select -r curve1 ;
duplicate -rr;
// Result: curve2 //
rotate -r -ws 0 -140.506888 0 ;
rotate -r -ws 0 -39.628589 0 ;
setAttr "curve2.rotateY" 180;
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 2 -jointOrient;
select -r curve1 ;
FreezeTransformations;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 2 -jointOrient;
expressionEditor EE "curve1" "translateX";
expression -s "curve1.scaleY = 1\r" -o curve1 -ae 1 -uc all ;
// Result: expression1 //
expression -s "curve1.scaleZ = 1" -o curve1 -ae 1 -uc all ;
// Result: expression2 //
select -r curve2 ;
expression -s "curve2.scaleX = curve1.scaleX" -o curve2 -ae 1 -uc all ;
// Result: expression3 //
expression -s "curve2.scaleY = curve2.scaleY" -o curve2 -ae 1 -uc all ;
// Result: expression4 //
expression -s "curve2.scaleZ = curve1.scaleZ" -o curve2 -ae 1 -uc all ;
// Result: expression5 //
expression -e -s "curve2.scaleY = curve1.scaleY" -o curve2 -ae 1 -uc all expression4;
// Result: expression4 //
expression -s "curve2.rotateX = curve1.rotateX" -o curve2 -ae 1 -uc all ;
// Result: expression6 //
expression -s "curve2.rotateY = -curve1.rotateY" -o curve2 -ae 1 -uc all ;
// Result: expression7 //
expression -s "curve2.rotateZ = curve1.rotateZ" -o curve2 -ae 1 -uc all ;
// Result: expression8 //
select -r curve1 curve2 ;
group; xform -os -piv 0 0 0;
RuffRuggedAndRaw
01-29-2010, 07:08 PM
I'm new here so I really appreciate it
ruchitinfushion
02-09-2010, 03:40 PM
can some body tell me expression for to make camera shake like explosion fx
rsj123
02-13-2010, 01:51 PM
Hi, can anyone please tell me how can I change the order of any particular vertex for any object?.thanks
rsj123
02-13-2010, 06:04 PM
can anyone please tell me how can i change the order of any particular vertex in any polygon mesh?
Thanks
Rohit
ewerybody
03-11-2010, 10:51 AM
he girls n guys! Just want to move this thread up to its initial purpose :]
// a popup on the right float field to make the currentTime the maximum range
popupMenu -p floatField4 -mm 1 -button 3;
menuItem -rp "E" -label "currentTime to range maximum" -command ("playbackOptions -max `currentTime -q`");
just put this in your userSetup.mel.
here is a short video: http://screencast.com/t/YTQxN2Y0Mjk
I always just wanted to make a simple stroke to do this. Now I have it ^^ yay!
I hope your range-flield is floatField4 as well.. unfortunately most of the Maya-elements don't have dedicated names. But here it wurks well :]
Maitreya
03-11-2010, 12:47 PM
hahahaha!!!this is my first mel script!!!
this procedure will delete all the animations (keyframes, ik effectors and expressions) in all the joints of a skeleton
when making a short film with my partner, the guy who make animation always complain that he cannot delete all the animations of a skeleton at a time....so I write this for him~(*^__^*)
a hahahaha~
global proc A_deleteAllKeys(string $A_rootNode)
{
//delete all keys
string $A_childNodes[]=`listRelatives -type joint -allDescendents -fullPath $A_rootNode`;
string $A_rN[]={$A_rootNode};
string $A_nodes[]=stringArrayCatenate($A_rN,$A_childNodes);
string $A_node;
for($A_node in $A_nodes)
{
cutKey $A_node;
//for each node,test if there is an expression, delete it if there is any
string $A_expressions[]=`listConnections -type expression $A_node`;
if(size($A_expressions)>0)
{
delete $A_expressions;
clear($A_expressions);
}
}
//delete all ik effectors
string $A_ikEffectors[]=`listRelatives -type ikEffector -allDescendents -fullPath $A_rootNode`;
if(size($A_ikEffectors)>0)
{
delete $A_ikEffectors;
}
}
androo2300
03-16-2010, 08:42 PM
Hmm...I made a thread of this but it doesn't show up...
Anyway, I made a Maya to After Effects script:
http://www.andyanimator.com/stuff/maya2AE/maya2AE_03.zip
It's a variation on Rob Bredow's script (http://www.185vfx.com/2003/03/convert-a-3d-point-to-2d-screen-space-in-maya/) that converts a selected object or vertex in Maya to 2D screen space in After Effects. I've added a GUI to the MEL script for camera selection and enabled multiple selections. If you export two points/objects from Maya the AE script that imports the data will automatically generate a Null with expressions that shows the scaling and rotation between the two points.
Thought I would try to get it out there so I could get some feedback and iron out any bugs. I'm especially interested to see if the tracking remains true across every possible camera setting (h/v aperture, film gate, etc.)
jaydru
03-18-2010, 10:42 PM
i just wrote this one thought it might be useful its to help when your trying to figure out whats going on with echo all commands, paste a string into the text field then hit the button, if its a mel proc, then that will be open with your default text editor
global proc whatIsIt(){
if (`window -ex whatIsit`)
deleteUI whatIsit;
window -menuBar 1 -t "What Is It" whatIsit;
menu -l "Help";
menuItem -l "About" -c "aboutWhatIsIt()";
$form = `formLayout`;
$tf = `textField whatIsTextField`;
$btn = `button -w 50 -l "?" -c "openIfMelProc( textField(\"-q\", \"-tx\", \"whatIsTextField\"))"`;
formLayout -e
-af $tf "top" 0
-af $tf "left" 0
-af $tf "bottom" 0
-ac $tf "right" 0 $btn
-af $btn "right" 0
-af $btn "top" 0
-af $btn "bottom" 0
$form;
showWindow whatIsit;
}
global proc openIfMelProc(string $text)
{
$whatIs = whatIs( $text );
if ($whatIs == "Command")
print "Command\n";
else if ($whatIs == "Unknown")
print "Unknown\n";
else
{
$path = stringToStringArray($whatIs, ":");
if (size($path) == 3)
{
print "Script\n";
system("load " + $path[1] + ":" + toNativePath($path[2]));
}
else
print "Unknown\n";
}
}
global proc aboutWhatIsIt(){
if (`window -ex "aboutWisitWin"`)
deleteUI aboutWisitWin;
window -s 0 -t "About" aboutWisitWin;
columnLayout;
text -l "\npaste a string into\nthe text field and\nthen press the button\nthere are 3 possible\nresults\n\n1. Command\n2. Unknown\n3. Mel Proc\n\nif the result is a\nmel proc then that\nscript will be opened\nwith your default\ntext editor\n\nJames Drew\n jaydru112@yahoo.co.uk";
showWindow aboutWisitWin;
window -e -wh 146 290 aboutWisitWin;
}
larryvm
04-09-2010, 08:28 AM
this is my first test with qt, is a maya to nuke camera exporter that i wrote some weeks ago, and now i put an interface in qt
the files are here (http://www.megaupload.com/?d=RIAYODYR)
http://img682.imageshack.us/img682/7320/exportcameraui.jpg
you must uncompress the file in my documents folder and you will get a new shelf with the script
jakefrombend
04-19-2010, 04:23 AM
No idea if this exists anywhere (I'm sure it does.) or if it's already been discussed here (I'm sure it has!) but here's a script that copies user defined attributes from one object to another, even if they don't exist on the destination object.
This is something I've wanted for like the last 10 years, but have been too lazy to build. I had some free time today, so I wrote it and will share it with you!
//
// Created by Jake Helms
// 2010/04/18
//
// This script copies user defined attributes
// from one object to another.
//
// To use:
// CopyUserDefinedAttributes "sourceObject" "destinationObject";
//
// Limitations:
// - Currently only supports the basic Maya attribute types
// - Does not support short names or nice name overrides
//
// Feel free to expand the functionality and re-share!
//
global proc CopyUserDefinedAttributes ( string $from , string $to )
{
string $ln_to = `longNameOf($to)`;
string $attrListFrom[] = `listAttr -userDefined $from`;
string $attrListTo[] = `listAttr -userDefined $to`;
// This removes destination attributes that are about to be copied
// if they exist on the source. This prevents attribute clashing.
for ( $attr in $attrListTo ) {
if ( `stringArrayContains $attr $attrListFrom`){
deleteAttr -at $attr $to;
}
}
for ( $attr in $attrListFrom ) {
string $attrType = `getAttr -type ($from + "." + $attr)`;
// vectors
if ( $attrType == "double3" ) {
float $val[] = `getAttr ($from + "." + $attr)`;
addAttr -ln $attr -at "double3" $ln_to;
}
// integers
if ( $attrType == "long" ) {
int $val = `getAttr ($from + "." + $attr)`;
string $cmd = ("addAttr -ln " + $attr + " -at long ");
if (`attributeQuery -node $from -minExists $attr`){
float $min[] = `attributeQuery -node $from -min $attr`;
$cmd += ("-min " + $min[0] + " ");
}
if (`attributeQuery -node $from -maxExists $attr`){
float $max[] = `attributeQuery -node $from -max $attr`;
$cmd += ("-max " + $max[0] + " ");
}
$cmd += ("-dv " + $val + " " + $ln_to);
eval $cmd;
}
// strings
if ( $attrType == "string" ){
string $val = `getAttr ($from + "." + $attr)`;
addAttr -ln $attr -dt "string" $ln_to;
setAttr -type "string" ($to + "." + $attr) $val;
}
// floats (doubles)
if ( $attrType == "double" ) {
float $val = `getAttr ($from + "." + $attr)`;
string $cmd = ("addAttr -ln " + $attr + " -at double ");
if (`attributeQuery -node $from -minExists $attr`){
float $min[] = `attributeQuery -node $from -min $attr`;
$cmd += ("-min " + $min[0] + " ");
}
if (`attributeQuery -node $from -maxExists $attr`){
float $max[] = `attributeQuery -node $from -max $attr`;
$cmd += ("-max " + $max[0] + " ");
}
string $parent[] = `attributeQuery -node $from -listParent $attr`;
if (`size $parent` == 1){
$cmd += ("-p " + $parent[0] + " ");
}
$cmd += ("-dv " + $val + " " + $ln_to);
eval $cmd;
}
// Booleans
if ( $attrType == "bool" ){
int $val = `getAttr ($from + "." + $attr)`;
addAttr -ln $attr -at "bool" $ln_to;
setAttr ($to + "." + $attr) $val;
}
// enumerated lists
if ( $attrType == "enum" ){
int $val = `getAttr ($from + "." + $attr)`;
string $enumList[] = `attributeQuery -node $from -listEnum $attr`;
string $enum = ($enumList[0] + ":");
addAttr -ln $attr -at "enum" -en $enum $ln_to;
setAttr ($to + "." + $attr) $val;
}
}
}
Let me know if it doesn't work for some reason. Didn't get to test it will all node types.
ewerybody
04-27-2010, 05:31 PM
Hey mayaScripters! Check this out:
a script that can freeze scale even if there are animation plugs attached:
Wanted this for years :]
{
string $sel[] = `ls -sl -tr -l`;
string $children[], $curve, $curves[3], $tIn, $cOut;
for ($t in $sel)
{
$curves = {};
string $ds[3] = {"x","y","z"};
// browse each scale-plug, disconnect anims, scale 1/x, remember them
for ($i = 0; $i < 3; $i++)
{
$tIn = ($t + ".s" + $ds[$i]);
$curve = getStringArrayItem0(`keyframe -q -name -at $tIn`);
if ($curve != "")
{
$cOut = $curve + ".output";
disconnectAttr $cOut $tIn;
scaleKey -iub false -vs (1 / getAttr($cOut)) -vp 0 $curve;
}
$curves[$i] = $curve;
}
// now freeze scale
makeIdentity -apply 1 -t 0 -r 0 -s 1 -n 0 $t;
// reattach the anim curves if there are any
for ($i = 0; $i < 3; $i++)
{
$tIn = ($t + ".s" + $ds[$i]);
$curve = $curves[$i];
if ($curve != "")
{
$cOut = $curve + ".output";
connectAttr $cOut $tIn;
}
}
}
} I will make it hierarchy aware another time...
light03
05-03-2010, 07:27 PM
Hi friends great efforts by all , well i need small help from u guys ,
m planing to list all the render layers from current scene n print them on MEL window UI , n so dat i can copy all the renderlayers once instead of doing it one by one ,
i am able to get all renderlayers printed in script editor by ls sl -type renderLayers technique ,
but wondering if i can get dem all printed one some MEL window interface so dat i can copy dem ,,,
my first post looking for some help ,,, thanks all
NaughtyNathan
05-03-2010, 08:28 PM
eh? why can't you just copy from the script editor..?
light03
05-03-2010, 08:34 PM
yes i can copy from de script editor , but the person who dont know sripts diffcult for dem n explain dem everytime , so i want to make a proper tool interface whr one can click button n all render layers get printed in window so dat it would b easy for everybody to just copy the data .
jaydru
05-03-2010, 10:30 PM
ScriptEditor;
handleScriptEditorAction "maximizeHistory";
handleScriptEditorAction "clearHistory";
print "//Curent Render Layers\n\n";
print `ls -type "renderLayer"`;
try that :thumbsup:
light03
05-04-2010, 05:49 AM
good one ... but friend i reached till here v can get output printed in script editor ,
but i want to make a interface for this script , which i am planing , with one window which would have one button which clicks , so that it prints the all render layers in that window itself in some text fields or something similar , so that we can copy ,
I am getting lots of ways to get all render layer printed in scrip editor but want to make a interface window ,
hope you getting my point , m newbie so you guys can suggest is dis possible to do so ,,,
thanks ,,,,
jaydru
05-04-2010, 08:52 AM
help -doc text;
should be able to get all you need to know from there :)
light03
05-04-2010, 09:21 AM
hey ya i tried that , if at all i could able to get my print output render layers in window but not able to copy anything , so need to find some output layout in which i can also copy data which it prints , similar like text fields but it just take input data..... m vry confused ,,, or anybody can try to make script for this .....
NaughtyNathan
05-04-2010, 09:47 AM
if you are hoping to "Copy" by RMB-clicking and picking "Copy" you are going to be disappointed. Only the script Editor allows this. All other copying is done by pressing Ctrl-C (on windows anyway) and that should work on any text-based UI fields.
I assume you already know that basics of making a window and layouts Harjit?
You should really start a proper post of your own on this.
:nathaN
light03
05-04-2010, 09:59 AM
Thnks for all your comments , i know i can copy ctrl+c in text fields , and i also know the basic of window making and layout , but problem is i am not able to get what i am looking for
not able to get render layers printed on UI interface and then copy it ,,,,
i am sori but first time i am talking help from forums , so plz forgive any mistakes ,,,,
Taunise
05-24-2010, 01:11 AM
This script creates shelf buttons and procedures for copying the translate, rotate, scale and pivot point of one object onto multiple objects. This script is based on original scripts by ewerybody and is my first finished script :)
I've attached it as a zip file, as it consists of 2 scripts, a readme and 4 icon image.s
Let me know if there are any issues or have any feedback :D
Note: This script is optimized for Maya 2011
Reeks
07-27-2010, 05:02 PM
I've put this one together for running scripts on multiple scenes. I probably wont release it on CreativeCrash, mainly because its only real use if for people who write their own scripts anyway. It's designed to sequentially load scene files, run a selected script, and resave the scenes before moving on. It's pretty straightforward, but a quick guide:
installation: RH_MultiScene.mel in you scripts dir. A subdir should be created in scripts too, called RHMS_Custom (more on that later). some sample scripts included.
http://www.ricoholmes.com/OtherStuff/Downloads/RHMS_Key.png
1) change the current scenes folder
2) check/uncheck all scenes
3) scenes list.. the almost invisible button at the end just loads that scene instantly.
4) checkbox to toggle scenes to process, (indicator light to the left to show successful completion).
5) Custom Scripts.. This is where the real meat is - it looks for scripts in a subfolder of Scripts called RHMS_Custom. Basically, if you need to make a small script and run it on a series of scenes, just drop your script in this folder and run RH_MultiScene :) (obviously no interaction possible during the batch running.) It'll find, source and run your selected script on multiple scenes.
Also works unexpectedly like a library for all the small silly 3-line scripts one might write :)
The zip can be found here (http://www.ricoholmes.com/OtherStuff/Downloads/RHMS_scripts.zip)
Oh yes, - and meant for Maya2011, not tested on previous versions.
ewerybody
07-27-2010, 11:03 PM
he Reeks! looking neat :]
we have something like that as well:
http://a.imageshack.us/img175/9314/rlforeach.png
Once set up by the programmers here.. but soon I changed almost everything under the hood. The thing I'm most proud of and which made it finally usable for a not-so-geeky-artist is the list. Its updated on change of the pattern fields. So you immediately see what its working on. You can even just delete items from there. Before you just had to give it some names and cross fingers..
Behind the "..." is a function to create scripts as well. Nice functionality here: I introduced several variables that you can use in the fired script:
save_scene (if you decide in the script the file shall be saved set this true. the tool will handle version control write enable and stuff)
first_loop (is true only in the first loop of course. this way you can ask for certain parameters that you might be looking for)
break_loop (if true it savely hops out of the process and still displays gathered stats)
nothing to release as well... its part of our toolchain. So biggups for releasing yours! :D
Say did you use Qt stuff? Or is this just simple mel-ELF-UI?
Reeks
07-28-2010, 08:25 AM
Thank you ewybody :)
Yes, I was really surprised to see there was nothing to do the job on CreativeCrash, and it's a remarkably useful concept - especially with the workflow we employ at the moment. Mutliple scene files are great, right up until a client wants changes ;p
Your "first_loop" sounds like a great idea. It's one of the things I would have like to put into mine (the ability to pause on an input requester output) but time was short and I'm still very new to mel programming. Frankly, it stumped me, so any advice there would be most welcome!
No QT at this point, just manual mel typing. I had a look at QT a few weeks back (all excited I was, too!) but felt like using ED209 to catch a mouse at that point ;D. I actually find UI design a little bit fun, (I know, first sign I'm not a programmer) so I don't mind manual entry.
again, thanks for the feedback, and hopefully it's of use to someone else too.
:)Reeks.
cyrus3v
08-06-2010, 08:54 AM
Hi everyone.
I finally finish this script very useful where I work. Basically, this script allows you to create a reference using a file which is a version higher than the one we are using. Tested on Maya 2010 and 2009.
On last thing. Its very important that in Open Scene click on the little box and check the option that says --> Ignore Version.
Attached Files Reference_ignoreVGUi.zip (1.5 KB, 0 views)
I can find here script (http://forums.cgsociety.org/showpost.php?p=6635308&postcount=5)
tsyra
08-26-2010, 08:34 AM
I just found this thread. I would like to share a script as well but I need help figuring out how to have it run at startup in Maya 2011 before it is complete. I made a custom drop drown menu to reduce screen clutter(check attachment) and I have all the commands working fine, just need to know how to have it run at startup. I've been searching online and there seem to be some reference to usersetup.mel. But I dont have that file ?
NaughtyNathan
08-26-2010, 09:24 AM
Hey Tareq, the userSetup.mel file doesn't exist by default as there are no user commands to run by default! You have to create it yourself (put it in your \my docs\maya\scripts\ folder if it's valid for all versions of Maya, or inside \my docs\maya\2011\scripts\ if it is version specific).
You don't really have to make your menu auto-run at startup, and most users will already have a userSetup.mel, so you should be ok just tellling people what command to add to the userSetup in your install instructions. Much easier than trying to write code to insert the command in their userSetup.mel!
is your new menu just a bunch of short-cuts to existing Maya options? couldn't you have just dumped all that stuff on a Marking Menu..?
:nathaN
tsyra
08-26-2010, 04:33 PM
Hey Nathan
My new menu is indeed a dump of normal maya commands. I was using the shelf all this time but grew tired of the icons, I prefer text menus. Also the toolbox on the left didn't serve any purpose except when I double-click to enter tool settings. So I combined the shelf and toolbox into one handy drop down that I can have open always. I tried Marking menu but personally I feel one click access beats click+hold+click.
I hid the shelf so I cannot run my script from it anymore so I prefer maya loading it automatically at startup. As for usersetup, what are the contents of this file ? Can I just rename my script to usersetup.mel ?
NaughtyNathan
08-26-2010, 05:48 PM
...As for usersetup, what are the contents of this file ? Can I just rename my script to usersetup.mel ?
good grief, no I wouldn't do that. Ideally your menu code should be in a global proc (let's assume it's called "tsyraMenu" and it's saved into into a script (text) file called "tsyraMenu.mel" in your my docs\maya\scripts (or version equivalent).
In your userSetup you just need to add a call to it, essentially just the line:
tsyraMenu;
you could encapsulate the call inside a catch just to be extra safe (especially if you add more stuff to the userSetup later!). If you don't have a userSetup.mel file simply create one.
:nathaN
tsyra
08-26-2010, 05:53 PM
Ok thanks, I think I got it. Yea it is saved currently on the desktop. I'm gonna mess with this see what I get thanks.
ewerybody
08-26-2010, 07:59 PM
on the desktopoh my!! you are quite a beginner aren't you? :D I mean no offence! We all started somewhere.. And sometimes people that don't have their heads already stuffed so deep into it bring up some fresh ideas.
But your habbit of working rather with that kind of floating menu instead of Hotkeys and context sensitieve Marking menus is a little strange..
You say "one click access beats click+hold+click" ?!?
Its actually:
* point your mouse to somewhere else where you aren't working (to a window thats blocking part of your viewport)
* look for an entry
* click it
* go back to the spot where you worked
against:
* hotkey (in case of move-, rotate-, scale-tool which are on W E & R, or duplicate!)
or:
* shift+RMB+leftstroke (if you want split polygon tool and have polys selected)
same for extrude (shift+RMB+downstroke), Select Edge Loop (doubleclick or ctrl+RMB+downrightstroke) Create Polygon Tool (nothing selected+shift+RMB+upstroke) Create Primitive (nothing selected+shift+RMB+MarkingMenu) Sculpt Geometry Tool (shift+RMB+upleftstroke)
I mean: sure you do your stuff for customizing! I really appreciate and always encourage that! But for me: MarkingMenus are a blessing! I learned a LOT about usablitiy design from that. The MMs in Maya are not perfect, there could be more colors or icons on the MMs or they could all be customizable easily (which they aren't, you (just) need to script of course).
Sometimes I wish there'd be markingMenus all around in the system! :D
tsyra
08-27-2010, 03:36 AM
The script editor was saving the script to a temp folder and as soon as I would close maya the mel file gets deleted. Thats why I saved it to the desktop. Once I figure out which folder it goes to I will move it there.
I use a tablet and I like one click. I have lost many many hours right click and holding and then choosing vertex and then right click and hold and choosing object mode. The only time I ever use the hotbox is to use the delete edge loop command. I don't see the point in going about it that way either because now I can double click on an edge to get the loop and just click on delete edge/vertex and I'm done. I try to simplify something for argument sake and you made me a bullet form list which I will use now to show you something:
1) Point your mouse to where you are not working - I can just click on the action I want to perform in my menu
2) Look for an entry - all my entries are ready in the drop down and probably already executed in step 1
3) Click it - Already done in step 1
4) Go back to the spot where you worked - Why ? I'm already 2-3 steps ahead because I avoided steps 2, 3 and 4 by now
5) shift+RMB+leftstroke, shift+RMB+downstroke - DIRECT one click access in my menu. All your shortcuts involve 2 keys and a mouse stroke :s
Since you took the time to show why you love it I am making an effort now to show you why I think you are wrong. You can enjoy your tried and trusted workflow and I would like to keep mine.
I need help with the startup mel file since I don't have one I don't even know what goes on in there. Nathan gave some feedback earlier but the fact still remains that I don't know what the contents of the file are. If you can help me with that, it would be awesome.
I have been working with the drop-down for a bit now, I added vertex/edge/face select modes on it as another tear off menu, undocked attribute editor, tool settings and channel box for full screen bliss :). I decided not to mess with the startup, I just opened a tab in script editor where the script is pasted, when I startup I just go there and run it. Seems to work well for me. :thumbsup:
ewerybody
08-27-2010, 09:49 AM
Like I said. No offense. You work like you do it. I'm just saying people took already a little care about stuff like that. Anyhow: Didn't know you wirking with a tablet. Sure: I know button-stroke combinations are teh crrp with that.
But thats actually another interface design flaw... because from that point of view MMs beat everything that exist:
only visible when needed
work at the spot where you are (mousemove takes time)
show only stuff that is currently possible (no bloat/distractions)
good for beginners: just hold and see whats there
good for pros: just stroke
so for that userSetup.mel: there is a command to find the spot where you need to put it:internalVar -userScriptDir;Thats yields the place for all your scripts you want to have at startup.
So if you have a .mel-file in there thats named tsyraSupertool.mel and there is a global proc inside with the name tsyraSupertool you can just start up Maya and hit a button that calls tsyraSupertool; OR: You can have it in the userSetup.mel: Just one line that says tsyraSupertool; Voila!
If you have it somewhere else you could also source your script from the userSetup.mel by calling:
source "c:/anylocation/tsyraSupertool.mel";
tsyraSupertool;
tsyra
08-27-2010, 11:06 AM
Thanks ewerybody. I will get on it.
Don't get me wrong, I always end up using marking menu's for creating cameras and lights, and some other stuff. But with my tablet pen its getting painful with the click and hold stuff. I used the shelf for a long time but I like the menu better.
mookiemu
08-27-2010, 11:30 AM
Thanks ewerybody. I will get on it.
Don't get me wrong, I always end up using marking menu's for creating cameras and lights, and some other stuff. But with my tablet pen its getting painful with the click and hold stuff. I used the shelf for a long time but I like the menu better.
Have you tried setting the buttons on the pen? You can have one set to be a right-click and the other to a middle-mouse click.
I currently have my pen set to have one of the buttons be a right-mouse click and the other set to an alt modifier (this is mainly because the alt is so useful for navigating and as a color picker in PS). I put the middle-mouse click on the eraser so when I need a middle mouse click I just flip the pen over like an eraser and hold the alt or other modifier buttons if I have to and it works really well.
Another option that a friend uses quite effectively is to have one of the pen buttons be a space-bar and he works with everything turned off in the gui and gets to all his menus that way.
Just a thought :)
ewerybody
08-27-2010, 11:36 AM
Yea no problem. But.. you know its not, that I "hold" if I know what I'm doing: If you are into it, its more like gestures. You don't have to wait for the MM to build up. Its a combination of sweep-directions with a combination of modifyers..
but yes: less modifyers > more convenient. When working on a laptop without mouse its pain as well. I'd love to get rid of one or the other mousebuttonclick.
but for instance the TimeDragger-Hotkey does different stuff with different buttons: K+LMB=TimeDragger, K+MMB=TimeDraggerWithoutValueChange
a good example of modifyer reduction:
Photoshop has the Space+LMB-panning (which is like Alt+MMB in Maya). Now Gimp came along and put this on "Space" only! Besides from 1000s of other crappy things in Gimp. THIS for example feels just too good!
tsyra
08-27-2010, 11:38 AM
Well you see, I got a bamboo fun medium. So everything is fine but the pen is not "fun" to use in long runs. As opposed to the intuous 3's and 4's pen. My pen tip is left click, then theres 2 buttons one is middle and the other is right click. I guess its the way I hold it because it hurts I find it hard to use the buttons on the side. So that is why I am trying this way..with the drop down. I haven't worked with the new setup yet, but I think its going to work out very nice hehehh.
I have a dual monitor setup so I am thinking about maybe using qt to design a 2nd window to be open full screen on the 2nd monitor to have tool settings, attribute editor and maybe some other stuff. Who knows, all in due time :)
ewerybody
08-27-2010, 11:44 AM
Well thats obviously a hardware problem :D
you could use Autohotkey (http://Autohotkey.com) to map certain key as mouseButtons if it doesn't feel good to press the keys on the pen...
SophiaSabir
08-30-2010, 07:35 PM
hey! i'm new in mel scripting. I want to change the size of an already existing model. i'm takin input from user. How is it possible to load some model created in maya? and then change the size life radius or height of it? i have the idea as to how can i change the size but the core problem here is how can i load the model??
SophiaSabir
09-03-2010, 01:26 PM
i found this forum very lively, thats why i made post here, can anyone help me? why i'm not getting any reply? :cry: i'm new in maya... i have my FYP in 3D modeling...
The core idea is that i have to create human models dynamically, on user input, like user when tells his/her body measurements, then i have to show him his very own dummy. i browsed internet and found out mel to b a solution (in my opinion) and now i did some practice ...but got stuck at one place, i'm making 3 cylinders in mel (just to see if the tech works) then took input from user in webpage and called a function test, that resides in a separate mel file, but in this function there is a line that throws error when it gets launched in maya. here are all my files.
1) test.htm
<html>
<head>
<TITLE>Make your own dummy...</TITLE>
<object width="550" height="400">
<param name="movie" value="MTB.swf">
<embed src="MTB.swf" width="550" height="400">
</embed>
</object>
<SCRIPT language="JavaScript">
function js_test()
{
var top =document.test_form.top.value;
var mid =document.test_form.mid.value;
var bottom =document.test_form.bottom.value;
var mel_url = "mel://test("+top + ", " +mid + ", " +bottom + ")/";
location = mel_url;
}
</SCRIPT>
</HEAD>
<BODY>
<a href="http://www.melscripting.com/">
go to melscripting.com
</a><p>
<FORM name="test_form" onSubmit="js_test(); return false;">
<B>enter your figure: </B>
<p>
<b>Top:</b>
<INPUT type="text" name="top" size="30"><P>
<b>Mid </b>
<INPUT type="text" name="mid" size="30"><P>
<b>Bottom </b>
<INPUT type="text" name="bottom" size="30"><P>
<INPUT type="submit" value="test">
</FORM>
</BODY>
</HTML>
2)make_web_test.mel
proc string get_path_url_test()
{
string $path_to_proc="whatIs make_web_test";
string $path_parts[];
string $lead_in = "Mel procedure found in:";
string $path_url = "file:/";
int $i;
$path_url = $path_url + substring($path_to_proc,(size($lead_in) + 1),size($path_to_proc));
tokenize $path_url "/" $path_parts;
$path_url = "";
for ($i = 0; $i < (size($path_parts) -1); $i++)
{
$path_url = $path_url + $path_parts[$i] + "/";
}
return $path_url;
}
global proc make_web_test()
{
string $myurl = (get_path_url_test() + "test.htm");
print ($myurl + "\n");
string $myWindow ="window -widthHeight 800 600";
columnLayout;
webBrowser -url $myurl;
showWindow $myWindow;
}
3)make_js_web_test.mel
proc string get_path_url_test()
{
string $path_to_proc = "whatIs make_js_web_test";
string $path_parts[];
string $lead_in = "Mel procedure found in: ";
string $path_url = "file:/";
int $i;
$path_url = $path_url + substring($path_to_proc,(size($lead_in) + 1),size($path_to_proc));
tokenize $path_url "/" $path_parts;
$path_url = "";
for ($i=0; $i<(size($path_parts)- 1); $i++)
{
$path_url=$path_url+ $path_parts[$i]+ "/";
}
return $path_url;
}
three_parts_ryt();
global proc test(float $top, float $mid, float $bottom)
{
$top=$top/8.333;
$mid=$mid/8.333;
$bottom=$bottom/8.333
//ive tried many scripts to make cylinders, but anything i try, it //throws error down here at these lines
polyCylinder -axis 0 5.034248 0 -height 3 -name "pCylinder1" -radius 2.0 -sx 12 -sy 1 -sz 1;
polyCylinder -axis 0 5.034248 0 -height 3 -name "pCylinder2" -radius 2.0 -sx 12 -sy 1 -sz 1;
polyCylinder -axis 0 5.034248 0 -height 3 -name "pCylinder3" -radius 2.0 -sx 12 -sy 1 -sz 1;
select -r pCylinder1 ;
scale -r $bottom 2.068992 $bottom ;
select -r pCylinder2 ;
scale -r $mid 2.068992 $mid;
select -r pCylinder3 ;
scale -r $top 2.068992 $top;
}
global proc browserBack()
{
global string $myWebBrowser;
webBrowser -e -back $myWebBrowser;
}
global proc browserForward()
{
global string $myWebBrowser;
webBrowser -e -forward $myWebBrowser;
}
global proc browserHome()
{
global string $myWebBrowser;
webBrowser -e -home $myWebBrowser;
}
global proc make_js_web_test()
{
global string $myWebBrowser;
string $myurl = (get_path_url() + "test.htm");
print ($myurl + "\n");
window -width 800 -height 632 -title "Make some spheres";
columnLayout;
rowLayout -numberOfColumns 3 -columnWidth3 32 32 32 -columnAlign 1 "right" -columnAttach 1 "both" 0 -columnAttach 2 "both" 0 -columnAttach 3 "both" 0;
iconTextButton -c "browserBack()" -image "back.JPG";
iconTextButton -c "browserForward()" -image "forward.JPG";
iconTextButton -c "browserHome()" -image "homepage.JPG";
setParent ..;
$myWebBrowser = "webBrowser -url $myurl";
showWindow;
}
HELP!!!
ive tried many things, but i guess my approach aint right.... thats why i get stupid errors, any function that i make, that has to change the position of cylinders along with creating them, it dznt create the cylinders... i totally have no idea whats wrong....
phix314
10-03-2010, 10:05 PM
Thought I'd come and share some of the scripts that I've written that have made the long-term cut.
To be sourced and run via SGT_SGTweakWindow(). See video at creativecrash here (http://www.creativecrash.com/maya/downloads/scripts-plugins/modeling/poly-tools/c/object-tweaker).
/*
Object Tweaker v 0.3 by Steven E. Geer
* Selected objects are given random rotation, translation, or scale values in X, Y or Z.
* Modify at own risk.
* Contact: stevenegeer (at) gmail
*/
global proc SGT_executeTweak(){
string $checkedAxes[];
string $checkedDir[];
string $empty[] = {""};
string $flagged[];
$checkedAxes[0] = (`checkBoxGrp -query -value1 axesCheckGroup`) == 1 ? "X" : "";
$checkedAxes[1] = (`checkBoxGrp -query -value2 axesCheckGroup`) == 1 ? "Y" : "";
$checkedAxes[2] = (`checkBoxGrp -query -value3 axesCheckGroup`) == 1 ? "Z" : "";
$checkedDir[0] = (`checkBoxGrp -query -value1 dirCheckGroup`) == 1 ? "-ro" : "";
$checkedDir[1] = (`checkBoxGrp -query -value2 dirCheckGroup`) == 1 ? "-t" : "";
$checkedDir[2] = (`checkBoxGrp -query -value3 dirCheckGroup`) == 1 ? "-s" : "";
string $finalCtxArray[] = stringArrayRemove($empty, $checkedAxes);
string $finalDirArray[] = stringArrayRemove($empty, $checkedDir);
float $finalAmount = `floatSliderGrp -query -value amountSliderGroup`;
float $multiplier = `floatSliderGrp -query -value multiplierGroup`;
$flagged[0] = (`radioButtonGrp -q -select translatePositioning` == 1) ? "-r" : "-a";
$flagged[1] = (`radioButtonGrp -q -select rotatePositioning` == 1) ? "-r" : "-a";
$flagged[2] = (`radioButtonGrp -query -select spaceRadioGroup`) == 1 ? "-ws" : "-os";
if((size($finalCtxArray) && size($finalDirArray)) != 0){
SGT_tweak($checkedAxes, $finalAmount*$multiplier, $checkedDir, $flagged);
}else{
error("You must have at least one axis and one context selected.");
}
}
global proc SGT_tweak(string $direction[], float $maxAmount, string $ctx[], string $flags[]){
float $amount;
int $i = 0;
int $curObject = 0;
string $sel[] = `ls -sl`;
string $attr;
if(size($sel) == 0){
error("You must have at least one object selected.");
}else{
string $rValues[];
string $tValues[];
string $sValues[];
int $isRot = 0;
int $isTrans = 0;
int $isScale = 0;
int $pAmount = 0;
progressWindow
-title "Tweaking..."
-progress $pAmount
-status "Tweaking Objects "
-isInterruptable true
-min 0
-max `size $sel`;
for($object in $sel){
float $startScale[] = `xform -r -q -s $object`;
float $delta;
if(`progressWindow -q -ic`) break;
$curObject++;
progressWindow -edit -status ($curObject+"/"+size($sel));
progressWindow -edit -progress $curObject;
for($cx in $ctx){
if($cx != ""){
switch($cx){
case "-ro":
$delta = rand($maxAmount * -1, $maxAmount);
for($i = 0; $i < 3; $i++){
$rValues[$i] = ($direction[$i] == "" ? "0" : $delta + " ");
}
$isRot = 1;
break;
case "-s":
$delta = rand( ($maxAmount*.1)*-1, $maxAmount*.1);
for($i = 0; $i < 3; $i++){
$sValues[$i] = ($direction[$i] == "" ? "0" : $startScale[$i] + ($delta) + " ");
}
$isScale = 1;
break;
case "-t":
float $delta = rand( ($maxAmount/2)*-1, $maxAmount/2 );
for($i = 0; $i < 3; $i++){
$tValues[$i] = ($direction[$i] == "" ? "0" : $delta + " ");
}
$isTrans = 1;
break;
}
}
}
//perform each move seperate
if($isRot == 1){
string $rn = stringArrayToString($rValues, " ");
string $tok[];
tokenizeList($rn, $tok);
string $command = ("xform "+$flags[2]+" "+ $flags[1] +" -ro ");
for($bar in $tok){
$command += ($bar + " ");
}
$command += ($object);
eval($command);
}
if($isTrans == 1){
string $tn = stringArrayToString($tValues, " ");
string $tok[];
tokenizeList($tn, $tok);
string $command = ("xform "+$flags[0]+" " + $flags[0] + " -t ");
for($bar in $tok){
$command += ($bar + " ");
}
$command += ($object);
eval($command);
}
if($isScale == 1){
string $sn = stringArrayToString($sValues, " ");
string $tok[];
tokenizeList($sn, $tok);
string $command = ("xform "+$flags[2]+" -s ");
for($bar in $tok){
$command += ($bar + " ");
}
$command += ($object);
eval($command);
}
clear $startScale;
if($curObject == size($sel)) progressWindow -endProgress;
}
}
}
global proc SGT_SGTweakWindow(){
if(`window -exists SGTweakerWindow`) deleteUI SGTweakerWindow;
if(`windowPref -exists SGTweakerWindow`) windowPref -remove SGTweakerWindow;
string $axes[] = {"X", "Y", "Z"};
string $context[] = {"r", "t", "s"};
float $amount;
string $tweakWindow =
`window -t "Tweak v 0.3" -s 0 -wh 400 230 -mnb true SGTweakerWindow`;
columnLayout -adj 1 columnContainer;
separator -h 10;
setParent columnContainer;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 5;
text -l "Axes" -w 100;
rowLayout -nc 1 -cw1 100;
checkBoxGrp -ncb 3 -la3 "X" "Y" "Z" -va3 true true true -cw3 70 70 70 axesCheckGroup;
setParent columnContainer;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 5;
text -l "Context" -w 100;
rowLayout -nc 1 -cw1 100;
checkBoxGrp -ncb 3 -la3 "Rotate" "Translate" "Scale" -va3 true false false -cw3 70 70 70 dirCheckGroup;
setParent columnContainer;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 5;
text -l "Tweak Amount" -w 100;
rowLayout -nc 1 -cw1 100;
floatSliderGrp -f true -min 0.0001 -max 5 -fmx 5 -fmn 0.0001 -pre 4 -v 1 amountSliderGroup;
setParent columnContainer;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 5 multCol;
text -l "Multiplier" -w 100;
rowLayout -nc 1 -cw1 100 multiCol1;
floatSliderGrp -f true -min .1 -max 5 -fmx 5 -v 1 -pre 1 multiplierGroup;
setParent columnContainer;
separator -height 20;
setParent columnContainer;
columnLayout -adj true -p columnContainer;
frameLayout -l "Flags" -cll 1 -pcc "int $winHeight = `window -q -h SGTweakerWindow`; window -e -h ($winHeight - 120) SGTweakerWindow;" -pec "int $winHeight = `window -q -h SGTweakerWindow`; window -e -h ($winHeight + 120) SGTweakerWindow;" -cl 1
flagGroup;
columnLayout -adj 1
localCol;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 5;
text -l "Space" -w 100;
rowLayout -nc 1 -cw1 100;
radioButtonGrp -nrb 2 -sl 1 -la2 "World" "Object" spaceRadioGroup;
setParent localCol;
separator -h 20 -vis 1;
setParent localCol;
frameLayout -l "Context Positioning" -cll 0 -mh 10 -mw 0 -li 150 -bs "etchedOut" -h 80
positionGroup;
columnLayout posLocal;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 1 "top" 5 -rat 2 "top" 5;
text -l "Translate" -w 100;
rowLayout -nc 1 -cw1 100;
radioButtonGrp -nrb 2 -sl 1 -la2 "Relative" "Absolute" translatePositioning;
setParent posLocal;
rowLayout -nc 2 -cw2 130 120 -cl2 "right" "left" -rat 2 "top" 4;
text -l "Rotate" -w 100;
rowLayout -nc 2 -cw1 100;
radioButtonGrp -nrb 2 -sl 1 -la2 "Relative" "Absolute" rotatePositioning;
setParent localCol;
setParent columnContainer;
separator -h 20;
rowColumnLayout -nc 2 -cw 1 175 -cw 2 175 -cal 1 "center" -cal 1 "center" -co 1 "left" 40 -co 2 "left" 40 -w 400 bottomCol;
button -w 200 -l "Apply" -c "SGT_executeTweak";
button -w 200 -l "Close" -c "deleteUI SGTweakerWindow";
showWindow $tweakWindow;
}
Simple snap A to B
global proc snapObject(){
string $sel[] = `ls -sl`;
if(size($sel) != 2){
error("You must have only 2 objects selected.");
}else{
string $parent = $sel[1];
string $child = $sel[0];
float $parentCoord[] = `xform -q -ws -t $parent`;
xform -ws -t $parentCoord[0] $parentCoord[1] $parentCoord[2] $child;
}
}
snapObject();
And a script to attach a bokeh node to a camera based on a selected object (Select Object, then Camera and run)
global proc bokeh(){
string $sel[] = `ls -sl`;
float $childPos[] = `xform -q -t $sel[0]`;
float $camPos[] = `xform -q -t $sel[1]`;
string $cShape[] = `listRelatives -s $sel[1]`;
string $cameraNode = $sel[1];
setAttr ($cameraNode + ".scaleX") 1;
setAttr ($cameraNode + ".scaleY") 1;
setAttr ($cameraNode + ".scaleZ") 1;
float $scaleX = `getAttr ($sel[1]+".scaleX")`;
string $bokehNode = ($sel[1]+"_bokeh");
string $ddShape = ($cShape[0]+"_ddm");
string $dd = `distanceDimension -sp $childPos[0] $childPos[1] $childPos[2] -ep $camPos[0] $camPos[1] $camPos[2]`;
rename $dd $ddShape;
string $con[] = `listConnections $ddShape`;
parent $con[1] $sel[1];
string $bokeh = `mrCreateCustomNode -asUtility "" mia_lens_bokeh`;
rename $bokeh $bokehNode;
float $distance = `getAttr ($ddShape+".distance")`;
float $correctedDistance = $distance / $scaleX;
connectAttr -f ($bokehNode+".message") ($cShape[0]+".miLensShader");
setAttr ($bokehNode+".plane") $correctedDistance;
}
bokeh();
RichardvonApplesauce
10-08-2010, 08:32 PM
First of all if this question is in the wrong place I apologize in advance, I am new to posting on forums. :wavey:
What I want to do is export vertex weights from a skin mesh in a format I can import into an OpenGL application. (Ideally without a library such as the FBX library)
I have a skin mesh attached to a skeleton in Maya. I can load .obj files into my OpenGL application so the model itself is not a problem. What I want to have is the numerical values of the weights for each vertex in my Maya model, and the bone those weights correspond to. I have a skeleton in OpenGL and this skeleton is driven in real time by a user. What I am looking for is a script to export the weights in a format such as .txt format so I can attach a skin mesh to this OpenGL skeleton.
Does anyone know of a script that will do this? If not is it worth the time to teach myself MEL to script this exporter or should I learn Python? I have written a few simple MEL scripts but I am familiar with JAVA so perhaps Python is the way to go?
zoo-prod
11-29-2010, 07:18 AM
Hi,
I'm building a UI for one of my characters Rigg.
It's almost done and works nicely so far. But I'm not totally happy with the selection method.
I'm using buttons to select the controllers. Those buttons are launching a "select" command.
Sometimes it would be nice to add to the current selection (-tgl tag) and sometimes it would be better to reset the selection (-r tag).
Here is exacly what I would like to achieve :
- When you simply click the button it launch a "select -r "command
- When you hold shift key on the keyboard and click the button it launch a "select -tgl" command
Is there's a simple way to do that?
Thank you.
NaughtyNathan
11-29-2010, 08:01 AM
This has been discussed many, many times before Boris... just do a search here for getModifiers, or select shift button.
:nathaN
zoo-prod
11-29-2010, 08:53 AM
Thanks Nathan.
That was what I was looking for. Perfect !
prithivimedia
01-04-2011, 10:51 AM
there is any script for recover corrupt .ma file ..........when i m opening it it stops at 85 percentage
James-Arlyle
01-06-2011, 03:02 AM
This script makes a simple gui that converts frame numbers from one frame-rate to another. It's useful for animating when your reference footage was shot with a frame-rate that's different from Maya's.
It's my first script and I hope that you all find it useful.
Thanks.
/* -----------------------------------------------------------------
* Quick Key Converter
*
* -Written by: Jonathan Strong 12/2010
*
* This script provides an easy to use frame number converter that converts
* frame numbers that use one frame-rate to frame numbers using a different frame-rate (ex: 24 fps to 30 fps).
*
* When sourced, the script will bring up the UI used to convert frame numbers automatically.
* To bring up the UI on your own, call QuickKey in the MEL command line.
*
* -----------------------------------------------------------------
*/
//*****************************************************************
//******************** private procedures *************************
/*------------------------------------------------
*
* makes the UI used to convert frame numbers
*
* ------------------------------------------------
*/
proc makeWindow(){
//standard window handling
if(`window -exists JS_QKeyUI`)
deleteUI JS_QKeyUI;
window -title "Quick Key Converter" -width 200 -height 400 JS_QKeyUI;
columnLayout mainCol;
//used to select Maya's frame-rate
radioButtonGrp -numberOfRadioButtons 3 -label "Maya Frame Rate" -vertical
-labelArray3 "24" "30" "Custom" -changeCommand QKey_enableCstm myaFPSgrp;
//used to specify a custom frame-rate for Maya
text -label "Custom Maya Rate";
textField -enable false -text "disabled" cstMyaFPS;
//used to select the reference footage's frame-rate
radioButtonGrp -numberOfRadioButtons 3 -label "Reference Frame Rate" -vertical
-labelArray3 "24" "30" "Custom" -changeCommand QKey_enableCstm refFPSgrp;
//used to specify a custom frame-rate for the reference footage
text -label "Custom Reference Rate";
textField -enable false -text "disabled" cstRefFPS;
//used to set the stepsize of the conversion
//(basically whether every frame, every other frame, every 3rd frame, etc. gets converted)
intSliderGrp -label "Frame Step" -field true -value 1 -min 1 -max 60
-changeCommand QKey_cnvrtFrames stepSlidr;
//displays the converted frame numbers
textScrollList frameList;
//textfields used to set the first frame of animation in Maya and
//the start and end frames of the reference footage
text -label "Maya Start Frame";
textField -text "1" myaStart;
text -label "Reference Start Frame";
textField -text "1" refStart;
text -label "Reference End Frame";
textField refEnd;
//button used to convert frame numbers
button -label "Convert keys" -c QKey_cnvrtFrames convrtBtn;
showWindow JS_QKeyUI;
}
/* -------------------------------------------
*
* gets the default frame-rate specified by the selection represented by $indx
* returns -1 if a default frame-rate does not exist for the selection
*
* --------------------------------------------
*/
proc float getDefaultVal(int $indx)
{
if($indx == 1)
{
return 24.0;
}
if($indx == 2)
{
return 30.0;
}
return -1;
}
/* -----------------------------------------------------------------------------------
*
* returns a float representing a user specified frame-rate, if the frame-rate isn't valid, the procedure returns -1
*
* ($txtFld is the textField whose text is the custom frame-rate)
*
* ------------------------------------------------------------------------------------
*/
proc float setCstFPS(string $txtFld)
{
//convert the textField's text to an integer
int $txtAsInt = (int)`textField -q -text $txtFld`;
//check to see if the integer is a valid frame-rate
if($txtAsInt > 0)
{
//if it is update the textField with the accepted frame-rate
textField -e -text ("" + $txtAsInt) $txtFld;
return $txtAsInt;
}
else{
textField -e -text "" $txtFld;
return -1;
}
}
/* --------------------------------------------
*
* returns a float representing the frame-rate determined by the UI, returns -1 if the frame-rate is invalid
*
* ($radGrp is the radioButtonGroup used to choose default or custrom frame-rates)
* ($txtFld is the textField used to specify a custom frame-rate)
*
* --------------------------------------------
*/
proc float getFPS(string $radGrp, string $txtFld)
{
//get the integer representing which radio button has been selected
int $sel = `radioButtonGrp -q -select $radGrp`;
if($sel != 3){
//if the selection is a default value return the default value for that selection
return getDefaultVal($sel);
}
else{
//return the custom frame-rate specified by the user
return setCstFPS($txtFld);
}
}
/* ------------------------------
*
* checks the text of the textField specified by $txtFld and returns an int based on its text
*
* ($default: the default value that should be used if no value is specified in $txtFld)
* ($err: the value that should be used if an invalid value is specified in $txtFld)
*
* ------------------------------
*/
proc int chkVal(string $txtFld, int $default, int $err){
int $val;
string $txt = `textField -q -text $txtFld`;
//if no value is specified, set the value to its default -- otherwise set $val based on $txt
if($txt == ""){
$val = $default;
textField -e -text ("" + $default) $txtFld;
}
else
$val = (int)$txt;
//checks to see if $val is invalid, if it isn't set it to $err and update $txtField with the valid value
if($val <= 0){
$val = $err;
textField -e -text ("" + $err) $txtFld;
}
else
textField -e -text ("" + $val) $txtFld;
return $val;
}
/* ------------------------------------------------
*
* gets the values for the start and end frames of the conversion
* and updates the textFields used to specify these frames
*
* returns an int[] of {$strtMaya, $strtRef, $endRef}
*
*--------------------------------------------------
*/
proc int[] getFrameVals()
{
//set variables for start/end frames based on the textFields used to specify them
int $strtMaya = chkVal("myaStart", 1, 0);
int $strtRef = chkVal("refStart", 1, 0);
//calculate the default value for the end of the reference footage (the default is one second past the beginning)
int $refFPS = (int)getFPS("refFPSgrp", "cstRefFPS");
int $endDefault = $strtRef + $refFPS;
//find the end of the reference footage
int $endRef = chkVal("refEnd", $endDefault, $endDefault);
int $frameVals[] = {$strtMaya, $strtRef, $endRef};
return $frameVals;
}
//*********************************************************
//*************** global procedures ***********************
/* -------------------------------------------------
*
* procedure the user calls to make and show the UI
*
* -------------------------------------------------
*/
global proc QuickKey()
{
//make and show the UI
makeWindow;
}
/* ------------------------------------------------------
*
* turns the textFields that allow the user to specify custom frame-rates
* on or off based on the user's selection in the myaFPSgrp & refFPSgrp radioButtonGrps
*
* ------------------------------------------------------
*/
global proc QKey_enableCstm(){
int $selMya = `radioButtonGrp -q -select myaFPSgrp`;
int $selRef = `radioButtonGrp -q -select refFPSgrp`;
if($selMya != 3)
textField -e -enable false -text "disabled" cstMyaFPS;
else{
string $txt = `textField -q -text cstMyaFPS`;
if($txt == "disabled")
textField -e -enable true -text "" cstMyaFPS;
}
if($selRef != 3)
textField -e -enable false -text "disabled" cstRefFPS;
else{
string $txt = `textField -q -text cstRefFPS`;
if($txt == "disabled")
textField -e -enable true -text "" cstRefFPS;
}
}
/* -----------------------------------------------------------------------------------------
*
* converts the frame numbers from one frame-rate to the other
*
* -----------------------------------------------------------------------------------------
*/
global proc QKey_cnvrtFrames()
{
//Maya's frame-rate and the frame-rate of the reference footage
float $myaFPS = getFPS("myaFPSgrp","cstMyaFPS");
float $refFPS = getFPS("refFPSgrp", "cstRefFPS");
if($myaFPS < 0)
error (" The value specified for Maya's frame-rate is not valid. ");
if($refFPS < 0)
error (" The value specified for the reference footage's frame-rate is not valid. ");
//get the values that determine the range of the conversion
int $validVals[] = getFrameVals();
int $strtMaya = $validVals[0];
int $strtRef = $validVals[1];
int $endRef = $validVals[2];
//get the step size for the for loop from the stepSlidr
int $stepSize = `intSliderGrp -q -value stepSlidr`;
//find out the frame number in Maya that corresponds to the last frame of the reference footage
int $endMaya = (int)((($endRef - $strtRef)/ $refFPS) * $myaFPS);
$endMaya += $strtMaya;
//used to format the contents of frameList to make it more legible
int $cntr = 0;
//fill up the textScrollList frameList with the converted frames
textScrollList -e -removeAll frameList;
textScrollList -e -append "Maya Frame \t Reference Frame" frameList;
textScrollList -e -append "______________________________" frameList;
for ( $x = $strtMaya; $x <= $endMaya; $x += $stepSize )
{
int $result = $x - $strtMaya;
$result = (int)(($result / $myaFPS) * $refFPS);
$result += $strtRef;
textScrollList -e -append ( $x + "\t" + $result) frameList;
if( ($cntr % 5) == 0 && $cntr > 0)
textScrollList -e -append "--------------------------" frameList;
$cntr++;
}
}
//******************** end of procedures *******************************
//makes and shows the UI when the script is sourced through the script editor
makeWindow;
ruchitinfushion
02-20-2011, 02:06 PM
Hey friends Let start Mel Script challenge on every month with different different topics.It will be fun,what you think huh??
Please Reply with your opinion.Thank you
BigRoyNL
03-03-2011, 08:32 PM
Sounds fun. :)
Geuse
03-03-2011, 09:08 PM
Nah, you'll just win! :shrug:
But I do agree, it would be very beneficial to learn how others chose to construct the same script function. :buttrock:
EMJAY
03-23-2011, 07:14 PM
Hi guys, newish to MEL. I want to be able to select an object at the top of a given heirarchy and search through the children below it to locate a particular type of object within the heirarchy. I have tried the listNodes command and also the ls -type command but this just returns all of the types of object I am looking for in the whole scene. Is there anyway to specify to just look within a selected heirarchy?
I am sure this is quite simple, but as I am still learning I would probably go a long way round when there is a quicker, better alternative.
Thanks
EMJAY
proc d_oh()
{
string $remindMe = "DONT FORGET THE COLON"
}
//Result: you forgot the colon
coding humour.......
FAIL
hahahahahhah. MEL is a fickle mistress, camelCase that code!:wip:
Taunise
03-23-2011, 07:44 PM
Try looking at the pickwalk command.
Hi guys, newish to MEL. I want to be able to select an object at the top of a given heirarchy and search through the children below it to locate a particular type of object within the heirarchy. I have tried the listNodes command and also the ls -type command but this just returns all of the types of object I am looking for in the whole scene. Is there anyway to specify to just look within a selected heirarchy?
I am sure this is quite simple, but as I am still learning I would probably go a long way round when there is a quicker, better alternative.
Thanks
EMJAY
proc d_oh()
{
string $remindMe = "DONT FORGET THE COLON"
}
//Result: you forgot the colon
coding humour.......
FAIL
hahahahahhah. MEL is a fickle mistress, camelCase that code!:wip:
NaughtyNathan
03-23-2011, 08:21 PM
hey Malcom, you should probably have started a new thread for this.. anyway, here's one solution:
ls -sl -dag -l -type "pointLight";the -sl flag is the most important in your case because it restricts the list to the selection, and the -dag flag tells it go list ALL the dag nodes underneath. The -l flag returns the long/full dag paths and the -type "pointLight" tells it to return only pointLights, obviously you would change this to your desired node type. You could even add a wildcard search term at the end to find pointlights with a specific name:
ls -sl -dag -l -type "pointLight" "*flicker*";
// will find any pointLight under the selected heirarchy that has "flicker" somewhere in its (shape) nameCheck the docs for ls as it is a MOST powerful listing function that many people overlook, coding stupidly long or inefficient functions to get something a single `ls` would manage.
The pickWalk command is for changing selection, and I don't think a very efficient way of working on items inside a script.
:nathaN
mookiemu
03-24-2011, 12:19 PM
hey Malcom, you should probably have started a new thread for this.. anyway, here's one solution:
ls -sl -dag -l -type "pointLight";the -sl flag is the most important in your case because it restricts the list to the selection, and the -dag flag tells it go list ALL the dag nodes underneath. The -l flag returns the long/full dag paths and the -type "pointLight" tells it to return only pointLights, obviously you would change this to your desired node type. You could even add a wildcard search term at the end to find pointlights with a specific name:
ls -sl -dag -l -type "pointLight" "*flicker*";
// will find any pointLight under the selected heirarchy that has "flicker" somewhere in its (shape) nameCheck the docs for ls as it is a MOST powerful listing function that many people overlook, coding stupidly long or inefficient functions to get something a single `ls` would manage.
The pickWalk command is for changing selection, and I don't think a very efficient way of working on items inside a script.
:nathaN
Nice, I always forget how powerful the ls command is, even in other languages!
Reeks
03-24-2011, 08:02 PM
[Snip]and the -type "pointLight" tells it to return only pointLights, obviously you would change this to your desired node type.
:nathaN
Ah this one caught my eye, due to the fact that I've been trying to put together a mel mixer board for VRay lights in a scene similar to one I did for MR/Maya lights. Unfortunately VRay lights only get listed as transform nodes, and the only way I've found of listing them so far* is messing around in the defaultLightSet. Nothing to specifically denote them as VRay.
Wildcarding "VRay" doesn't help if they've been renamed either :/
*with obviously limited Mel script knowledge.
NaughtyNathan
03-24-2011, 08:08 PM
Hey Reeks, long time no see.. Every geomeric/physical/moveable object in Maya consists of a parent transform and a shape node below, meshes, nurbs, lights, cameras, action-er-etc.. I have no idea what vRay lights are but they must have a shape node below their transform that hold their visible locator and their light properties.
select one and then type: ls -sl -dag -st which should return something like:
// Result: vrayLight01 transform vrayLightShape01 vrLight
which shows the transform name, then it's type, then it's shape name and shape type.
:nathaN
Reeks
03-24-2011, 08:20 PM
Hey Reeks, long time no see..
Oh always in the background, soaking up the knowledge. Actually, mel scripting for me is sporadic and usually due to situational needs.
And good, god you're fast on the ball as ever !
Every geomeric/physical/moveable object in Maya consists of a parent transform and a shape node below, meshes, nurbs, lights, cameras, action-er-etc.. I have no idea what vRay lights are but they must have a shape node below their transform that hold their visible locator and their light properties.
select one and then type: ls -sl -dag -st which should return something like:
// Result: vrayLight01 transform vrayLightShape01 vrLight
which shows the transform name, then it's type, then it's shape name and shape type.
:nathaN
Ohh dear... so simple!
// Result: VRayLightSphere1 transform VRayLightSphereShape1 VRayLightSphereShape //
Thank you NN! I can honestly say it's your input (as well as JSChiek) that makes the learning of mel scripting enjoyable. One of these fine days I'll take the Python Plunge, but still got a long way of learning the mel ropes to go first as you can tell ;p
EMJAY
03-30-2011, 09:01 AM
Hi guys, thanks for the replies.
What can I say, except D`oh.
Had managed to source a solution which is what you guys have suggested but I am very grateful that there are peeps like you guys ready to offer advice. I seem to overcomplicate things when writing MEL, often going the long way, but each day is a bit easier.
Will be posting the code for what I have been working on shortly.
Thanks
sdinesh86
03-31-2011, 08:26 AM
Hello,
here is my first attempt towards MEL scripting
i have done a quick Blueprint Manager to ease in the task of setting up planes shaders etc for Vehicle / character Modelling.
i am still learning so there might be a few issues here and there but will solve those, once i get good idea and reference on MEL.
Toggles double sided on selected objects. Handy to keep polys down.
for ($node in $selection)
{
if ( getAttr ($node + ".doubleSided") == 1)
{
setAttr ($node + ".doubleSided") 0;
}
else
{
setAttr ($node + ".doubleSided") 1;
}
};
Also, I lost my binding for softSelection so had to write something for that:
int $softVar = `softSelect -q -sse`;
switch ($softVar)
{
case 1:
softSelect -sse 0;
break;
case 0:
softSelect -sse 1;
break;
}
And lastly, found a good script :Maya Mel script Better Combine (http://www.bg3d.com/archives/872)
Keeps grouping, merges meshes together if verticies are close and centers pivot. What Maya's combine should be.
NaughtyNathan
04-07-2011, 10:56 PM
for toggling values using NOT (!) helps reduce and simplify your code a lot:
for ($node in `ls -tr -sl`)
setAttr ($node+".doubleSided") (!`getAttr ($node+".doubleSided")`);
// and:
softSelect -sse (!`softSelect -q -sse`);
I'm not sure how useful a double sided toggle would really be though, rather than a simple "make singleSided"... but each to their own. :)
:nathaN
for toggling values using NOT (!) helps reduce and simplify your code a lot:
for ($node in `ls -tr -sl`)
setAttr ($node+".doubleSided") (!`getAttr ($node+".doubleSided")`);
// and:
softSelect -sse (!`softSelect -q -sse`);
I'm not sure how useful a double sided toggle would really be though, rather than a simple "make singleSided"... but each to their own. :)
:nathaN
Hey cheers, I read about that method but couldn't quite get it :D
simha.sai
04-29-2011, 12:19 PM
This is mel i Use for playblast
playblast -startTime 8 -endTime 13 -format avi -filename "C:/playblasts/test" -forceOverwrite -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -fp 4 -percent 100 -compression "MS-CRAM" -quality 95 -widthHeight 524 268;
I need startTime -endTime to selected / highlighted frame-range
molgamus
06-10-2011, 09:16 PM
Hey all!
Trying to set a unique expression on every object after its creation, how to?
global proc randomPlacement(float $amount ,float $width ,float $depth)
{
for ($i=0; $i<$amount; $i++)
{
polySphere -sx 16 -sy 8;
//movement along the y-axis
string $sel[] = `ls -sl`;
expression -e -s ($sel[0] + ".translateY = sin(time);") -o $sel[0] ;
//place on the xz-plane
float $randomX = rand(-$width,$width);
float $randomZ = rand(-$depth,$depth);
move -x $randomX;
move -z $randomZ;
}
}
The expression-part does not work for me.
KarenLasz
06-29-2011, 05:17 AM
hey guys
im trying to make hot keys for slide, edge select, and add edge loop but i cant figure out the mel script to paste in the hot key editor. i did delete edge loop just fine but i cant figure out the other three. any one know what part i need to copy ?
thanks
AlexSudnikov
07-19-2011, 06:50 PM
The expression-part does not work for me .
Try this :
global proc randomPlacement(float $amount ,float $width ,float $depth)
{
for ( $i = 0; $i < $amount; $i++ )
{
select -cl;
string $newlyCreatedSphere[] = `polySphere -sx 16 -sy 8`;
//movement along the y-axis
expression -o $newlyCreatedSphere[0] -s "translateY = sin(time);" ;
//place on the xz-plane
float $randomX = rand(-$width,$width);
float $randomZ = rand(-$depth,$depth);
select $newlyCreatedSphere[0];
move -x $randomX;
move -z $randomZ;
}
}
ewerybody
08-10-2011, 12:36 PM
smee again! :D I just found some script that I obviously got from the standard Maya scripts but altered a bit to fix an extremely annoying issue when switching panel styles: This keeps all the shading settings alive (xray, backfaceculling, wos...) and JUST switches the layout:global proc setPaneLayout_keepPanelSettings( string $whichNamedLayout ) {
global string $gMainPane;
string $configName = `getPanel -cwl $whichNamedLayout`;
string $panelType;
string $panelName;
string $visPanels[4];
int $exists = false;
int $i,$numberOfPanels;
if (`panelHistory -exists "mainPanelHistory"`)
panelHistory -e -suspend true "mainPanelHistory";
if (!`paneLayout -exists $gMainPane`)
error ("$gMainPane: \"" + $gMainPane + "\" cannot be found!\n");
// get state arrays.
int $fixed[] = `panelConfiguration -q -isFixedState $configName`;
string $labels[] = `panelConfiguration -q -labelStrings $configName`;
string $types[] = `panelConfiguration -q -typeStrings $configName`;
string $create[] = `panelConfiguration -q -createStrings $configName`;
string $edit[] = `panelConfiguration -q -editStrings $configName`;
// loop each panel in this configuration
// build an array of visible panels and make sure that
// they are parented to the main pane.
$numberOfPanels = `panelConfiguration -query -numberOfPanels $configName`;
for ($i = 0; $i < $numberOfPanels; $i++) {
$panelName = `getPanel -withLabel $labels[$i]`;
// if panel exists:
if ($panelName != "")
{
// if panel has no parent:
if ("" == `panel -q -control $panelName`) {
$panelType = `getPanel -typeOf $panelName`;
eval ($panelType + " -e -p $gMainPane " + $panelName);
}
// omit if panel is torn off
if (`panel -q -to $panelName`) {
string $msg = (uiRes("m_setNamedPanelLayout.kCantUsePanel"));
string $pnl = `panel -q -label $panelName`;
warning `format -s $pnl $msg`;
$visPanels[$i] = "";
} else {
$visPanels[$i] = $panelName;
}
if ($fixed[$i]) {
//
// Reset state.
//
string $editStr = ("int $menusOkayInPanels = `optionVar -q allowMenusInPanels`; string $editorName; string $panelName = \""+ $panelName + "\"; "+ $edit[$i]);
// print("$editStr: \"" + $editStr + "\"\n");
// eval ($editStr);
}
}
}
paneLayout -e -manage false $gMainPane;
for ($i = 0; $i < $numberOfPanels; $i++) {
if ("" != $visPanels[$i]) {
print ("paneLayout -e: " + $visPanels[$i] + " " + ($i+1) + "\n");
paneLayout -e -setPane $visPanels[$i] ($i+1) $gMainPane;
}
}
eval `panelConfiguration -q -cfs $configName`;
paneLayout -e -manage true $gMainPane;
setFocus `paneLayout -q -p1 $gMainPane`;
if (`panelHistory -exists "mainPanelHistory"`)
panelHistory -e -suspend false "mainPanelHistory";
updateToolbox();
}
I don't know where I originally got it from. But I found it to be a blessing! I mean I switch styles maybe 1000 times a day and having the settings ffed up each time was SO horrible. So I though someone would like that too. Here you go :]
smee again! :D I just found some script that I obviously got from the standard Maya scripts but altered a bit to fix an extremely annoying issue when switching panel styles: This keeps all the shading settings alive (xray, backfaceculling, wos...) and JUST switches the layout:
Sounds great, I get this problem too. How do I use this script?
ewerybody
08-12-2011, 05:38 PM
Sounds great, I get this problem too. How do I use this script?He dnos! Thanks.
1. Put the script in your userScriptDir //python:
(cmds./mc./)internalVar(userScriptDir=1)
//mel:
internalVar -userScriptDir;
in a file called the same as the global proc name setPaneLayout_keepPanelSettings.mel (or make it both shorter if you want)
2. find what Layouts you want to switch to. You find the names on the toolBox buttons in the mouseOver tooltip or you RMB there and look through the list or you click Edit Layouts in this menu and goto the Layouts tab. There you could also select and copy/paste from the Label field.
3. Setup hotkeys or shelfButtons that call:
setPaneLayout_keepPanelSettings "yourLayoutName";
Unfortunately this does not simply overwrite the layout switching mechanism of Maya. I don't know if thats possible. Maybe override setNamedPanelLayout to that? AH! Thats obviously the procedure that I ripped the parts from! Yea one could do that too. But you never know when Maya sources from the original files again.
Tell me if things work out :]
Ah I'd love to be able to use it with the sidebar buttons than the shelf. I've made a custom UV/persp layout that I use all the time, but it looses the settings everytime.
Anyway to use those? Im on maya 2009 so I guess the UI aint as easy to modify as 2011+
stcgladiator
08-26-2011, 09:53 PM
ok so im working on a small small for a animated scene. I have a modelled a lampost and used a a spotlight as the light source for it, and i have a point light source to represent the sun. What i need to do is create a Mel script to make the point light (sun) rise up on the Y axis and back down again, whist this is happening i need the spotlight to turn on and off accordingly. when the sun sets the light turns on, and when the rises up in the sky the light should turn off. another extra i need with this is to simulate a small effect when the sun sets and the light turns on, it should warm up. so it should turn red for a short second then change to its yellow color.
I understand very little about mel scripting and need some basic guidance on how to set up this sort of script and then use it as a animation with my scene.
Any help on this would be very appreciated, thanks.
float $time = `currentTime -query` ;
float $translateY = `getAttr pointLight1.translateY` ;
if( $translateY >= 10 )
{
setAttr "spotLightShape1.intensity" 0 ;
setAttr "pointLightShape1.intensity" 1 ;
}
else
{
setAttr "pointLightShape1.intensity" 0 ;
}
if( $time < 80 )
{
setAttr "spotLightShape1.color" 2 1 1 ;
setAttr "spotLightShape1.intensity" 1 ;
}
else
{
setAttr "spotLightShape1.color" 1 1 1 ;
}
if( $time > 287 )
{
setAttr "spotLightShape1.intensity" 0 ;
}
else
{
setAttr "spotLightShape1.intensity" 1 ;
}
This is what ive got so far, but i need to loop this piece of code for the 1000frames of my animation and put it into a procedure if possible to simplify it. I really am crap at mel and cant figure it out :\
Geuse
08-27-2011, 11:34 PM
This is mel i Use for playblast
playblast -startTime 8 -endTime 13 -format avi -filename "C:/playblasts/test" -forceOverwrite -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -fp 4 -percent 100 -compression "MS-CRAM" -quality 95 -widthHeight 524 268;
I need startTime -endTime to selected / highlighted frame-range
I'm not sure if this is of importance to you anymore, since your post was some months old.
Anyway, the global string $gPlayBackSlider will give you the name of the slider and the command timeControl will let you query the selected frame range of that slider.
timeControl -q -ra $gPlayBackSlider;
If using this in a script don't forget to declare the string as it's global.
global string $gPlayBackSlider;
Bryan Ewert's site has some really good info. That and the maya help command site is the resources I use most.
http://xyz2.net/mel/mel.027.htm
Good luck!
James-Arlyle
08-28-2011, 04:07 AM
ok so im working on a small small for a animated scene. I have a modelled a lampost and used a a spotlight as the light source for it, and i have a point light source to represent the sun. What i need to do is create a Mel script to make the point light (sun) rise up on the Y axis and back down again, whist this is happening i need the spotlight to turn on and off accordingly. when the sun sets the light turns on, and when the rises up in the sky the light should turn off. another extra i need with this is to simulate a small effect when the sun sets and the light turns on, it should warm up. so it should turn red for a short second then change to its yellow color.
I understand very little about mel scripting and need some basic guidance on how to set up this sort of script and then use it as a animation with my scene.
:\
I think you're overthinking the problem; trying to write a mel script for this isn't really necessary. You should be able to set up the effects you want with a few Set Driven Keys.
You can set it up so that the streetlamp turns on and off, and the pointlight changes color based on the pointlight's position. Then all you have to do is animate the pointlight moving up and down, and you'll get the desired effect.
stcgladiator
08-28-2011, 03:09 PM
I think you're overthinking the problem; trying to write a mel script for this isn't really necessary. You should be able to set up the effects you want with a few Set Driven Keys.
You can set it up so that the streetlamp turns on and off, and the pointlight changes color based on the pointlight's position. Then all you have to do is animate the pointlight moving up and down, and you'll get the desired effect.
yeah but the part of my assignment requires this to be done without manual animation, but through scripting only, i could animate all this by hand easily but i just dont understand scripting one bit :cry:
James-Arlyle
08-28-2011, 04:17 PM
Alright then, if it's scripting for an assignment you need, I'll try to give you some tips to get you going.
(as a side note, I've not wrote mel for a while so I might have some syntax errors in my examples)
First off, to loop something, I'd use the modulus operator %, the modulus operator works by giving you the remainder of a division operation, so 5 % 2 = 1, 10 % 6 = 4, etc.
You can loop an animation by doing something like this:
$animLen = 24;
$time = `currentTime -q`;
$crntFrame = $time % $animLen;
This will give you a repeating sequence of numbers that goes from 0 to 23. You can then use $crntFrame to drive an attribute of an object.
setAttr aLight.translateY, (10 * $crntFrame);
I'd then suggest using expressions to drive the other behaviors you're seeking. Their syntax is a bit different but they shouldn't be too difficult to write.
Something like:
if ( sunLight.translateY > 20 )
streetLight.intensity = 1;
else
streetLight.intensity = 0;
If you need to write the expressions from within a script you can use the expression command in mel:
expression -s "aObj.translateX = aShape.translateY";
If you have more questions, start out by looking at the mel command reference and the resources in Maya's help files. There's plenty of examples there that should be able to help guide you on your way.
stcgladiator
08-29-2011, 04:18 PM
Alright then, if it's scripting for an assignment you need, I'll try to give you some tips to get you going.
(as a side note, I've not wrote mel for a while so I might have some syntax errors in my examples)
First off, to loop something, I'd use the modulus operator %, the modulus operator works by giving you the remainder of a division operation, so 5 % 2 = 1, 10 % 6 = 4, etc.
You can loop an animation by doing something like this:
$animLen = 24;
$time = `currentTime -q`;
$crntFrame = $time % $animLen;
This will give you a repeating sequence of numbers that goes from 0 to 23. You can then use $crntFrame to drive an attribute of an object.
setAttr aLight.translateY, (10 * $crntFrame);
I'd then suggest using expressions to drive the other behaviors you're seeking. Their syntax is a bit different but they shouldn't be too difficult to write.
Something like:
if ( sunLight.translateY > 20 )
streetLight.intensity = 1;
else
streetLight.intensity = 0;
If you need to write the expressions from within a script you can use the expression command in mel:
expression -s "aObj.translateX = aShape.translateY";
If you have more questions, start out by looking at the mel command reference and the resources in Maya's help files. There's plenty of examples there that should be able to help guide you on your way.
right ok thanks for the help, much appreciated :) i will see what i put together.
smee again! :D I just found some script that I obviously got from the standard Maya scripts but altered a bit to fix an extremely annoying issue when switching panel styles: This keeps all the shading settings alive (xray, backfaceculling, wos...) and JUST switches the layout:
I may have found another solution to this: It seems the default maya layouts do not do have settings specified for xray/backface/etc and therefore they stay consistent when switching.
So I went into userprefs.mel and replaced a portion of the default persp/outliner with my custom layout (which was loaded with settings for xray/backface/etc).
Solved!
Chepri
08-31-2011, 10:27 AM
Here's a script for manually adjusting your skin color and clossyness. It's a melscript GUI with limited sliders.
if ( `window -exists MyGuiWindow` ) {
deleteUI MyGuiWindow;
}
{
// create window
window -title "GUI" MyGuiWindow;
columnLayout;
// Skin attributes
text -l "Skin";
attrFieldSliderGrp -label "Red Skin – Yellow Skin" -minValue 15 -maxValue 40 -at ("hsvToRgb1.inHsvR");
attrFieldSliderGrp -label "Saturation" -minValue 0.2 -maxValue 0.5 -at ("hsvToRgb1.inHsvG");
attrFieldSliderGrp -label "Dark-Light Skin" -minValue 0.2 -maxValue 1 -at ("hsvToRgb1.inHsvB");
attrFieldSliderGrp -label " Dry – Greasy Skin " -minValue 0.0 -maxValue .3 -at ("hsvToRgb3.inHsvB");
showWindow MyGuiWindow;
}
You need to add 2 HSVToRGB Nodes to your skin material, one conected by color and one by specular. Then it should work.
Take care!
NandoNkrumah
09-08-2011, 07:21 PM
Hi,
I try to create a simple script that uses the window command to rename a file.
The script is not finished but even the first step didn't work. I am not a programmer so I got stuck early with some syntax problems.
string $winCMD = "REN";
string $fileWithPath = " O:/3Dtest/01.jpg";
string $newFileName = " 03.jpg";
string $fullCMD;
$fullCMD = $fileWithPath + $newFileName;
system($winCMD + $fullCMD);
The mel script does this thing: REN O:\3Dtest\01.jpg 03.jpg"
It simply renames one image into another.
It works in a .bat file so it should theoretically work out of Maya but I get a syntax error message.
Any ideas how to fix the script?
Thank you!
NandoNkrumah
09-08-2011, 08:06 PM
... or lets say I want to use the (system) copy command inside maya:
string $winCMD = "copy /y";
string $fileA = " O:/3Dtest/saveTextureA/03.jpg";
string $fileB = " O:/3Dtest/tempTextureA/01.jpg";
system($winCMD + $fileA + $fileB);
gives a syntax error.
Why???
WesHowe
09-08-2011, 08:18 PM
I played with that here, with minor changes to the actual path and name. It does not work with forward slashes in the file specs.
Change the second line to this:
string $fileWithPath = " O:\\3Dtest\\01.jpg";
Note I replaced the forward slashes with TWO back slashes, as a single backslash is an 'escape' character in MEL strings.
<* Wes *>
NandoNkrumah
09-08-2011, 09:04 PM
Thank you Wes,
now it is working :)
benio33
09-09-2011, 07:36 AM
Actually for working with paths in relation Maya -> Windows there is a "toNativePath" command:
Note: Extracted from Maya help:
string $file = `workspace -q -fn`;
// Result: D:/Projects/projectOne/scene2 // On Windows
string $path = toNativePath( $file );
// Result: D:\Projects\projectOne\scene2 // On Windows
So you should do:
string $fileA = " O:/3Dtest/saveTextureA/03.jpg";
$fileA = toNativePath( $fileA );
And it would work just fine.
ps. For going the other way Windows -> Maya use "fromNativePath" command.
depakeen
09-09-2011, 03:15 PM
Hi,
i've read the very first post of this thread, and i found that to have a cubic helper was quite useful. Unfortunatly, the cube is not at the center of the world and have fixed values. So I've changed the script a little bit. Tell me if it helps ! (sorry, i'm really a newbie)
four scripts :
- CreateSplineCube.mel
- CreateSplineCubePrompt.mel
and two others for the shelf buttons.
first part, the cube itself ("CreateSplineCube.mel"):
global proc JPL_CubeSpline (int $sizeSide)
{
if ($sizeSide > 0) //useful if the user did not type an integer
{
curve -d 1
-p $sizeSide $sizeSide $sizeSide -p $sizeSide $sizeSide (-$sizeSide)
-p (-$sizeSide) $sizeSide (-$sizeSide) -p (-$sizeSide) $sizeSide $sizeSide
-p $sizeSide $sizeSide $sizeSide -p $sizeSide (-$sizeSide) $sizeSide
-p (-$sizeSide) (-$sizeSide) $sizeSide -p (-$sizeSide) $sizeSide $sizeSide
-p (-$sizeSide) $sizeSide (-$sizeSide) -p (-$sizeSide) (-$sizeSide) (-$sizeSide)
-p (-$sizeSide) (-$sizeSide) $sizeSide -p $sizeSide (-$sizeSide) $sizeSide
-p $sizeSide (-$sizeSide) (-$sizeSide) -p (-$sizeSide) (-$sizeSide) (-$sizeSide)
-p (-$sizeSide) $sizeSide (-$sizeSide) -p $sizeSide $sizeSide (-$sizeSide)
-p $sizeSide (-$sizeSide) (-$sizeSide)
-k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16;
xform -cp;
rename ControlCube1; //Maya will automatically increment if you create other cubes
}
else
error "not a valid value. Try again !";
}
second part, the code that creates a prompt window to set the size of the cube ("CreateSplineCubePrompt.mel"):
global proc JPL_PromptCubeDialog ()
{
int $sizeSide;
string $result = `promptDialog
-t "Create a cubic helper"
-m ("Please type the size of the cube:")
-b "OK" -b "Cancel"
-db "OK" -cb "Cancel"
-ds "Cancel"`;
if ($result == "OK")
{
$sizeSide = `promptDialog -q -tx`;
source "CreateSplineCube.mel";
JPL_CubeSpline ($sizeSide);
}
}
The script to launch from the shelf with the prompt window :
source "CreateSplineCubePrompt.mel";
JPL_PromptCubeDialog ();
The last one to create the cube with a fixed value (change "5" by whatever you want) :
source "CreateSplineCube.mel";
JPL_CubeSpline (5);
TheN8man
09-25-2011, 09:13 PM
Just thought I'd put up a simple script I made when I was just starting out... But then I thought I'd add some revisions to make it more user proofed; The concept is quite easily adapted for doing the same task to multiple objects, which is mostly what I did when starting out, especially with certain buttons in Maya that only let you do something to one object at a time.
Usually I abbreviate everything that can be abbreviated (like `ls -sl` etc) but I left most of this one in full for the less familiar peoples.
This script is for when a lot of duplicates have been positioned etc. but the user wants to replace the UVs on them all, from a UVed copy.
(note that the transferAttributes command leaves history on the object. It also assumes the default UV map, `map1`, is being copied.)
(? Anyone know how to paste something into this editor without it being reformatted and losing all it's indents etc?! How is anyone supposed to put python here I wonder...)
(Edit: Actually, once posted a lot of the formatting is restored. But not all.)
/////////////////////////////////////////////////// // transferUVsToAll.mel //
// //
// (Select the prototype to copy UVs from last.) //
// //
// Simple MEL script by Nathan Chisholm //
///////////////////////////////////////////////////
global proc transferUVsToAll ()
{
// Store current selection
$sel = `ls -selection`;
/// Error precaution: Verify selection ///
if (size($sel)<2) error "Select meshes to copy UVs to, and select the mesh to copy from last.";
for ($selObj in $sel)
// Make sure all selected objects are meshes, for UV transferral
{
$selShapes = `listRelatives -s $selObj`;
if ( ! (`objectType -isType mesh $selShapes[0]`)) error ($selObj + " isn't a mesh. Select meshes to copy UVs to, and select the mesh to copy from last.");
};
/// == ---------------------------------- == ///
// Save the last selected object as the 'prototype' to copy UVs from
$prototype = $sel[size($sel)-1];
print("Prototype = " + $prototype);
// Deselect prototype, leaving all other objects selected, and save new selection
select -d $prototype;
$allofthem = `ls -selection`;
for ($eachthing in $allofthem)
// Transfer UVs to each object in turn
{
transferAttributes -transferPositions 0 -transferNormals 0 -transferUVs 2 -transferColors 2 -sampleSpace 4 -sourceUvSpace "map1" -targetUvSpace "map1" -searchMethod 3-flipUVs 0 -colorBorders 0 $prototype $eachthing;
print("Done " + $eachthing + "/n");
};
// Reselect all except the prototype, print finish statement
select $allofthem;
print("Coffee break over.");
};
// Run the defined procedure.
transferUVsToAll();
nbreslow
11-21-2011, 08:01 PM
Hi All,
I am looking for a specific Maya script that was highlighted by Eric Miller in a BodyPaint course I took online at Gnomon. The script is part of his Maya - BodyPaint render setup workflow and is very simple. It will update all selected file textures extensions (.bmp, .sgi, etc.) in a Maya scene with a new extension. I am including a screen shot of the script in action from one of his videos.
I have tried searching everywhere with a lot of different keywords but haven't been able to find it. Also, I posted over at Gnomon but wanted to see if anyone here remembers it? Hopefully someone does. Thanks in advance!
-nbreslow
nbreslow
11-21-2011, 08:32 PM
It is called RenameFileExtension with NO SPACES and can be found on Creative Crash. Doh!
-nbreslow
eissahesham
11-26-2011, 11:38 AM
Hi all,
I'd like to share this script http://www.creativecrash.com/maya/downloads/scripts-plugins/rendering/mental-ray/c/light-control-he_lightcontrol
It controls all scene lights and Mental Ray Indirect lighting with one UI. Make sure Mental Ray plugin is loaded and your renderer set to Mental Ray.
I hope its ok that I put the link instead of pasting the code.
Enjoy!
eissahesham
12-20-2011, 10:08 PM
Hi all,
If you liked my Light Control tool, then download the new version from http://www.creativecrash.com/maya/downloads/scripts-plugins/rendering/mental-ray/c/light-control-he_lightcontrol
I would love to get some feedback from users.
nbreslow
12-21-2011, 07:51 PM
eissahesham,
First - great script! Clean and intuitive. I have had an issue with it where, after using it, my attributes window becomes unresponsive. I can scroll it, or open up a section but I don't see anything happen until I switch tabs then switch back. Not sure if it just me but I have tested it out a few times with the same result.
A few suggestions:
1) Enhance Light List - See this link (http://download.autodesk.com/us/mudbox/help2010/index.html?url=WS1a9193826455f5ff-6d855556117c23ce11b-403c.htm,topicNumber=d0e2579) for a view of the Mudbox Object List. See how it has toggles for Visibility and Locks? Also, the little arrow above is a filter and could be used to filter lights by type. Maybe more of a small icon route to select all, isolate, etc. You could use some of the Maya Viewport icons or default ones to keep the look consistent.
2) Filters - Maybe a way to filter the list by name or wildcard?
3) Look Through Selected - I use this feature a lot, might be nice.
4) Access to render settings.
5) Some custom tool like a script to autosetup an area light parented to a spotlight? Or a way to add a custom attribute to a light?
Look forward to more updates. Thanks,
-nbreslow
eissahesham
12-21-2011, 09:33 PM
Hi nbreslow,
First off, thank you very much for taking the time to post this, I really appreciate it.
Second, about the problem you have with the attribute editor, I just tried it a few times on different scenes and I didn't have that problem. If you get the opportunity, try it on another machine and let me know if you find the same problem.
Lastly, I really like all your suggestions and I'll incorporate them in the new update plus some other features. I have two questions though, I never heard about parenting an arealight to a spotlight, is that to have the spotlight cast shadows and the arealight emit light only? or am I misunderstanding this?
My second question is about the custom attribute, do you mean like "Modify-->Add Attribute.." or are you talking about a specific custom attribute you want?
Thanks again nbreslow, I appreciate your effort very much.
nbreslow
12-21-2011, 10:40 PM
Hiya,
I'll try the script on my other machine at home and see what's up and let you know. I use the NEX plugin from draster but I never had a problem with it before not playing nice with other stuff. I also use a bunch of other scripts - not sure what it could be.
Check out this link (http://oliverwolfson.com/studio-light-hdr-images/). This is really what I meant - nice little light setups. Some stuff like this would really enhance your script. Make it more of a light maker/controller. Not sure if this is what your after..just a thought.
Regarding the attribute thing - sometimes it is nice to add in a custom attribute so you have it in case you need to separate things out in a script at render or whatever. Not essential - I mostly use it on objects that should not receive AO but some people might use it for lights. Something like this:
addAttr -at byte -longName miLabel -k 1 -defaultValue 0;
Hope that helps and thank you!
-nbreslow
eissahesham
12-21-2011, 11:24 PM
Thank you very much nicholas, that was very educational. Those light setups are so awesome, I will definitely do something similar.
Let me know when you try the script at home.
About the custom attribute, I will add that option as well.
eissahesham
02-21-2012, 08:31 AM
This script allows you to select similar poly objects like the feature in 3ds max. Copy the code and assign it to a hotkey.
//====================================================
// Global proc for selecting similar poly Objects
//====================================================
global proc he_selectSimilar ()
{
string $newSelection[];
string $selected[] = `ls -sl`;
int $selVertices[] = `polyEvaluate -vertex $selected[0]`;
float $selecArea[] = `polyEvaluate -worldArea $selected[0]`;
string $allPolyObjects[] =`ls -exactType mesh`;
for ($each in $allPolyObjects)
{
int $toCompareVertices[] = `polyEvaluate -vertex $each`;
float $toCompareArea[] = `polyEvaluate -worldArea $each`;
if ($selVertices[0] == $toCompareVertices[0] && floatEq ($selecArea[0], $toCompareArea[0]))
{
$newSelection[`size $newSelection`] = $each;
}
}
select $newSelection;
clear $newSelection;
}
he_selectSimilar;
ajk48n
03-09-2012, 11:00 PM
hey all,
I'd like to a share a script I made for controlling rotation/scaling/shapes of objects based on a sphere of influence.
http://adamkatz.ffsmultimedia.com/scripts/mel/Radial_Influence.mel
Basically, you have a bunch of driven objects, and a base object. Your change the rotation/scale/shape of the base object, and the driven objects takes those properties based on how far away it is from a control sphere object.
To use, select a bunch of objects that you want to be driven, and then select the base object. The base object must be selected last. Run the script, and there will be a sphere at the origin that is your influence object.
Also, the base object should have frozen transformations for rotate and scale before the script is run.
It's probably simpler to explain with an example, so here's a Maya file. It's an Ascii file from Maya 2011. There's quite a few objects in this scene, so it may take a little time to open.
http://adamkatz.ffsmultimedia.com/scripts/scenes/Demonstration_Scene-v1.ma
There are also some controls available on the influence object.
You can control:
a random amount of rotation and scale for each of the driven objects
the seed for the random number
the outer radius where the influence is 0%
the inner radius where the influence is 100%
a random radius of influence
"Inner Follows Outer" which determines if the inner influence is a percentage of the outer influence
Please let me know if it doesn't work, or if you have any suggestions.
Pranaw
03-17-2012, 05:38 AM
Hi everyone,
im sharing this script i wrote which allows you to do most type of constraints, multiple times.
http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/pgp-multi-constraint-v--2
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.