Maya Mel
Jump to navigation
Jump to search
Contents
- 1 Maya Mels Scripts
- 1.1 Octane Render Baking group id - Assign id to multiple objects shapes
- 1.2 Maxwell Render - Particles sequence - Force .abc file
- 1.3 Maxwell Render - Specify object ID color
- 1.4 Redshift - Add blend attribute and set random value for objects selection
- 1.5 Redshift - Set Primary visibility off for selection (layer override)
- 1.6 Convert Motion trail to curve
- 1.7 Quantize keyframes for selection
- 1.8 Loop image sequence for texture
- 1.9 Symmetrize - Duplicate & merge object
- 1.10 Mirror object
- 1.11 Group each object and rename
- 1.12 Change path in an Attribute
- 1.13 Change opacity mode on V-Ray shaders
- 1.14 Change color space on selected fileTextures
- 1.15 Redshift - custom Tesselation on selected objects
- 1.16 Change color on selected shaders
- 1.17 Change Filter Type on selected Files Textures
- 1.18 Clean Render Layers
- 1.19 Change Filter Type on selected Files Textures
- 1.20 Select by name
- 1.21 Display color on shapes
- 1.22 Geometry Constraint on multiple selection
- 1.23 Set bump multiplier on multiple V-Ray shaders
Maya Mels Scripts
Octane Render Baking group id - Assign id to multiple objects shapes
// 0 is for Red, 2 for Green, 4 for Blue // 3, 5 and 6 for Cyan, Magenta and Yellow // Replace the number "0" by the number of your choice // Baking group id is also avalaible in Attribute Spreadsheet Editor for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".octBakGrId") (0); }
Maxwell Render - Particles sequence - Force .abc file
//This expression force Maya to reload an Alembic particles file at each frame - there is no other way in Maxwell Render to read a particles sequence in .abc global int $current_frame; $current_frame = `currentTime -query`; print $current_frame; { setAttr -type "string" maxwellRFRKParticles1.file ("/YOUR_PATH/YOUR_FILE" + $current_frame + ".abc"); }
Maxwell Render - Specify object ID color
// Specify object ID color for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".mxSpecifyObjIdColor") (1); setAttr ($object + ".mxObjIdColor") -type "double3" 1 0 0; }
Redshift - Add blend attribute and set random value for objects selection
// Useful for blending between colors with RedshiftUserDataScalar for ( $object in `ls -sl -l` ) { print($object); addAttr -ln "blend" -at double -min 0 -max 1 -dv 0 $object; setAttr ($object + ".blend") (rand(1)); }
Redshift - Set Primary visibility off for selection (layer override)
// Go in right render layer and select objects for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".rsEnableVisibilityOverrides") (1); editRenderLayerAdjustment ($object + ".rsPrimaryRayVisible"); setAttr ($object + ".rsPrimaryRayVisible") (0); }
Convert Motion trail to curve
// Select the motion trail first { $selected=`ls -dag -et snapshotShape`; for ($obj in $selected){ $pts=(getAttr($obj+".pts")); $size=size($pts); $curve=`curve -d 1 -p $pts[0] $pts[1] $pts[2] -p $pts[4] $pts[5] $pts[6] -k 0 -k 1`; for($i=8;$i<$size;$i+=4) curve -os -a -p $pts[$i] $pts[$i+1] $pts[$i+2] $curve ; } }
Quantize keyframes for selection
// Snap keys on frames for objects selection for ( $object in `ls -sl -l` ) { print($object+"\n"); snapKey $object; }
Loop image sequence for texture
// On File texture, check Image sequence, and edit expression file1.frameExtension=((frame%8)+1);
Symmetrize - Duplicate & merge object
// Select half object first for ( $object in `ls -sl -l` ) { print($object+"\n"); xform -piv 0 0 0 $object; duplicate -rr; setAttr ($object + ".scaleX") (-1); select -add $object ; polyPerformAction polyUnite o 0; polyMergeVertex -d 0.0001 -am 1 -ch 1; DeleteHistory; rename ($object); }
Mirror object
// Select object first for ( $object in `ls -sl -l` ) { print($object+"\n"); DeleteHistory; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1; xform -piv 0 0 0 $object; duplicate -rr; setAttr ($object + ".scaleX") (-1); DeleteHistory; }
Group each object and rename
// Select objects first for ( $object in `ls -sl -l` ) { string $name = ($object); select $object ; doGroup 0 1 1; rename ($name + "_GRP"); }
Change path in an Attribute
// Here the Attribute is ".filePrefix" - Select objects first for ( $object in `ls -sl -l` ) { string $path = getAttr ($object+".filePrefix"); $path = `substitute "//OLD/PATH/" $path "//NEW/PATH/"`; setAttr -type "string" ($object+".filePrefix") ($path); }
Change opacity mode on V-Ray shaders
// Select shaders first for ( $object in `ls -sl -l` ) { if (attributeExists("omode",$object)) { //check if attribute exists CBunlockAttr ($object+".omode"); //unlock opacity mode } if (attributeExists("opacityMode",$object)) { setAttr ($object+".opacityMode") 1; //set opacity mode in Clip - 0 pour Normal } } // Alternative for ( $object in `ls -sl -l` ) { if (attributeExists("opacityMode",$object)) { setAttr ($object+".opacityMode") -l false; //unlock attribute if locked } if (attributeExists("opacityMode",$object)) { setAttr ($object+".opacityMode") 2; //set opacity mode in Clip - 0 pour Normal } }
Change color space on selected fileTextures
// Useful to automatically convert Quixel Megascans by example from sRGB/Raw to ACES color spaces string $object_selection[] = (`ls -sl`); for ($object in $object_selection) { if(`getAttr ($object+".cs")` == "sRGB"){ setAttr ($object + ".cs") -type "string" "Utility - sRGB - Texture"; } if(`getAttr ($object+".cs")` == "Raw"){ setAttr ($object + ".cs") -type "string" "Utility - Raw"; } }
Redshift - custom Tesselation on selected objects
// Select objects first for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".rsMinTessellationLength") (0.1); setAttr ($object + ".rsMaxTessellationSubdivs") (2); setAttr ($object + ".rsOutOfFrustumTessellationFactor") (4); }
Change color on selected shaders
// Select shaders first for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".color") -l false; setAttr ($object + ".color") -type "double3" (0.18) (0.18) (0.18); }
Change Filter Type on selected Files Textures
// Select files textures first - 0 means Off for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".filterType") 0; }
Clean Render Layers
// In MEL fixRenderLayerOutAdjustmentErrors;
Change Filter Type on selected Files Textures
// Select files textures first - 0 means Off for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".filterType") 0; }
Select by name
// Select objects with "blabla" select -r "blabla*";
Display color on shapes
// Select objects for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".displayColors") 1; setDisplayColorChannelAttribute ($object + ".displayColorChannel"); polyColorPerVertex -r 1 -g 0 -b 0 -a 1 -cdo; }
Geometry Constraint on multiple selection
// Select objects to constrain string $objectBase = "surfaceName"; for ( $object in `ls -sl -l` ) { select -cl; select $objectBase; select -add $object; geometryConstraint -weight 1; select -r "*Constraint*"; doDelete; } === Speed up smokes rendering with V-Ray === <pre> // Select smokes first for ( $object in `ls -sl -l` ) { print($object+"\n"); setAttr ($object + ".rendStep") 160; setAttr ($object + ".shadowStep") 400; }
Set bump multiplier on multiple V-Ray shaders
// Select shaders for ( $object in `ls -sl -l` ) { if (attributeExists("bumpMult",$object)) { setAttr ($object + ".bumpMult") -1; //set bump multiplier at -1 } }