selectPref -clickDrag (!`selectPref -q -clickDrag`);
useful for animation in some case to click and drag an object with one click
Showing posts with label mel. Show all posts
Showing posts with label mel. Show all posts
7/4/17
1/10/16
MAYA / VRAY / MEL _ viewport snapshot in Vray VFB
// Vray VFB viewport snapshot
// create it in maya's renderview then load it in Vray VFB
global proc VrayVFBsnapshot ()
{
// create snapashot from current viewport camera
RenderViewWindow; // open renderview
string $panel = `getPanel -wf`;
string $camera = `modelEditor -q -camera $panel`;
renderWindowRenderCamera snapshot renderView $camera; // create snapshot
// get path to TMP image
string $workspaceDir = `workspace -q -fullName`;
string $imageDir = `workspace -q -fileRuleEntry "images"`;
string $imagePath = $workspaceDir + "/" + $imageDir + "/" + "TMP_snapshot";
print $imagePath;
sysFile -delete ($imagePath+".jpg"); // delete previous snapshot -- Windows
setAttr "defaultRenderGlobals.imageFormat" 8; // set maya software to .jpg to save it as a jpg
renderWindowSaveImageCallback "renderView" $imagePath ""; // save snapashot to .jpg file
// open image in vray vfb
vrayShowVFB; // open Vray VFB
vray vfbControl -loadimage ($imagePath+".jpg");
}
5/20/15
MAYA / MEL_ offset animation multiple objects
// Proc to offset animation keyframe - two mode random or increment
// select controllers and run the command : OffsetKeyFrame random 6 or OffsetKeyFrame increment 2
global proc OffsetKeyFrame (string $type, int $value)
{
string $sel[] = `ls -sl`;
if ($type == "increment")
{
int $val = 0;
for ($item in $sel)
{
keyframe -e -iub true -r -o over -tc $val $item;
$val += $value;
}
}
else if ($type == "random")
{
for ($item in $sel)
{
int $rnd = rand(0,$value);
keyframe -e -iub true -r -o over -tc $rnd $item;
}
}
select -r $sel;
}
11/16/14
MAYA / MEL _ flat shaded viewport
edit : Now in Maya 2015 there is an option for that in the viewport -> lighting -> use flat lighting.
I didn't find a simple way to display a flat shaded viewport. So here is a simple script to toggle the viewport with a flat shaded view, usefull to see silouhette when animating. This mel script create a global render layer with a surface shader material override, to change the flat color just modify the surface shader.
I didn't find a simple way to display a flat shaded viewport. So here is a simple script to toggle the viewport with a flat shaded view, usefull to see silouhette when animating. This mel script create a global render layer with a surface shader material override, to change the flat color just modify the surface shader.
// TOGGLE FLAT - using render layer
global proc toggleFlat ()
{
if (`editRenderLayerGlobals -q -currentRenderLayer` == "defaultRenderLayer")
{
// Check if Render Layer FLat exists or create it
if (`objExists "RL_FLAT"`)
{
editRenderLayerGlobals -currentRenderLayer RL_FLAT;
}
else
{
createRenderLayer -n "RL_FLAT" -number 1 -makeCurrent -global;
// SHADER ///
string $shadName = "SH_FLAT";
// Check if Shader doesn't exists and create it
if (!`objExists $shadName`)
{
$shader = `shadingNode -n $shadName -asShader surfaceShader`;
setAttr ($shader + ".outColor") -type double3 0.7 0.7 0.7;
}
hookShaderOverride("RL_FLAT", "", "SH_FLAT");
editRenderLayerGlobals -currentRenderLayer RL_FLAT;
}
headsUpMessage "FLAT ON";
}
else
{
editRenderLayerGlobals -currentRenderLayer defaultRenderLayer;
headsUpMessage "FLAT OFF";
}
}
toggleFlat ();
9/21/14
MAYA/MEL _ toggle
//Toggle Isolate Selected in Current Panel
$currentPanel = `getPanel -withFocus`;
$state = `isolateSelect -q -state $currentPanel`;
if ($state == "0")
{
enableIsolateSelect $currentPanel 1;
}
else
{
enableIsolateSelect $currentPanel 0;
}
// Toggle SHaded WIreframe
string $panel = `getPanel -wf`;
modelEditor -e -wos ( !`modelEditor -q -wos $panel` ) $panel;
//ToggleOutliner:
if ( `window -exists outlinerPanel1Window` )
deleteUI -window outlinerPanel1Window;
else
tearOffPanel "Outliner" "outlinerPanel" false;
MAYA/MEL _ second outliner
tearOffPanel "Outliner1" "outlinerPanel" false; tearOffPanel "Outliner2" "outlinerPanel" false;
Subscribe to:
Posts (Atom)