Hi,
I just released version 1.0 of anozie_tools. Hope you find it helpful. Modify at your own risk.
Here's the git link:
https://github.com/nathanielanozie/anozie_tools
Here are some example screenshots for menu:
I use the modeling and skinning menus quite frequently.
Cheers,
Nate
Showing posts with label Mel Scripts. Show all posts
Showing posts with label Mel Scripts. Show all posts
Wednesday, March 25, 2015
Thursday, January 15, 2015
Toggle wireframe Maya MEL script
Hi,
I wrote this today because i was finding i often made like 3 or so clicks to show or hide wireframe during deformation making. With this hotkey it makes it much faster. Hope you find it helpful.
cheers,
Nate
I wrote this today because i was finding i often made like 3 or so clicks to show or hide wireframe during deformation making. With this hotkey it makes it much faster. Hope you find it helpful.
//toggle wireframe active panel
string $window = `getPanel -withFocus`;//example modelPanel1
if( `modelEditor -q -wos $window` == 0 ){
modelEditor -e -wos 1 $window;
}
else{
modelEditor -e -wos 0 $window;
}
cheers,
Nate
Labels:
Mel Scripts
Tuesday, October 14, 2014
Select Cluster of Hierarchy (MEL), Create ik sc (MEL)
Hi,
Here are a couple scripts i wrote that are beginning to be useful in using mocap animation to preview some rigging deformation.
Cheers,
Nate
Here are a couple scripts i wrote that are beginning to be useful in using mocap animation to preview some rigging deformation.
//select all cluster in all selected roots
//Author: Nathaniel Anozie (ogbonnawork at gmail dot com)
//nathananozie dot blogspot dot com
global proc na_selectClusterOfHierarchy(){
string $result[] = {};
string $sel[] = `ls -sl`;
for($arg in $sel){
string $past[] = {};
$past =`listConnections $arg`;
string $hist[] = `ls -type cluster $past`;//cluster history
if(size($hist) == 1){ $result = stringArrayCatenate($result, $hist);//save it
}else{}
}//end loop
$result = stringArrayRemoveDuplicates($result);
select -r $result;
}
na_selectClusterOfHierarchy();
//create ik sc use selected root, assumes has child
//inspired by Anop A.K (codecg dot com) learning about iksc drawing in mel
string $sel[] = `ls -sl`;
if(size($sel) == 1){
string $root = $sel[0];
select -r $root;
string $check[] =`listRelatives -children -type joint $root`;
if(size($check) != 1){ error("Error Nothing to Draw IK SC with, check end"); }
pickWalk -direction down;//using this so get full path
string $children[] = {};
$children = `ls -sl -type joint`;
if(size($children) != 1){print("Error Nothing to end IK SC at");}
else{
string $end = $children[0];
select -r $root $end; //make ik sc
ikHandle -sol ikRPsolver;
select -cl;
}
}
Cheers,
Nate
Labels:
doodles,
Mel Scripts
Friday, October 10, 2014
Some Selection tips using MEL in Maya
Hi,
Here are a couple of tips i wrote for selecting objects of a certain type for viewing in Maya.
The first tip is
These two are helpful for adding something or removing something from the isolated viewed thing.
This tip helps with selecting all things from a hierarchy, like say select all cluster handles, or joints (just change -type "clusterHandle" to -type "joint")
On the side im finding it helpful to preview mocap animation by using a linear curve that follows the leg or arm (where cvs are clustered and parented to the mocap rig). By doing this it is easier to see frames we wish to use from mocap animation.
Also im finding using iksc handles helps to get translate based mocap animation to give joints rotation values. Check out my Mel tips for rigging on vimeo for some insight into geo adding to joint tools and segment tools, this will come in very handy for getting a quick proxy geo view of mocap data.
Cheers,
Nate
Here are a couple of tips i wrote for selecting objects of a certain type for viewing in Maya.
The first tip is
isolateSelect, it is incredibly helpful to make a simpler scene to work on by just seeing what we wish to .
These two are helpful for adding something or removing something from the isolated viewed thing.
isolateSelect -addSelected modelPanel4; isolateSelect -removeSelected modelPanel4;
This tip helps with selecting all things from a hierarchy, like say select all cluster handles, or joints (just change -type "clusterHandle" to -type "joint")
global proc na_selClusterHInHierarchyFromSelectedRoot(){
//---select all joints in hierarchy of selected root
string $sel[] = `ls -sl`;
if(size($sel) == 1){
select -hierarchy; select -r `ls -sl -type clusterHandle`;
}
else{
warning("Treating Each thing selected as a Root !!!\n");
//error("Requires a single selected root !!!\n");
string $addToSel[] = {};
for($arg in $sel){
select -r $arg;
select -hierarchy; select -r `ls -sl -type clusterHandle`;
$addToSel = stringArrayCatenate($addToSel, `ls -sl`);
select -cl;
}
$addToSel = stringArrayRemoveDuplicates($addToSel);
select -r $addToSel;
}
}
na_selClusterHInHierarchyFromSelectedRoot();
On the side im finding it helpful to preview mocap animation by using a linear curve that follows the leg or arm (where cvs are clustered and parented to the mocap rig). By doing this it is easier to see frames we wish to use from mocap animation.
Also im finding using iksc handles helps to get translate based mocap animation to give joints rotation values. Check out my Mel tips for rigging on vimeo for some insight into geo adding to joint tools and segment tools, this will come in very handy for getting a quick proxy geo view of mocap data.
Cheers,
Nate
Labels:
doodles,
Mel Scripts
Monday, September 8, 2014
Hotkey switch Rotate mode in Maya
Hi,
Today i was working on some rigging deformations in Maya and I wanted to be able to quickly rotate joints either in world space or in gimbal mode, so i wrote a short hot key to do this.
Hope you find it helpful.
--Using smooth mode with all but two influences locked to get fleshy areas working better after some preliminary weighting is done.
--Using move skin joint tool to experiment with better joint positioning
--Using a plane to figure out how to create joint chains to rotate okay, and also be on ok axis for ikhandle's etc to work well.
cheers,
Nate
Today i was working on some rigging deformations in Maya and I wanted to be able to quickly rotate joints either in world space or in gimbal mode, so i wrote a short hot key to do this.
Hope you find it helpful.
//toggle between rotate gimbal versus rotate world, useful during skinning
{
int $mode = `manipRotateContext -q -mode Rotate`;
//if your in gimbal put in world otherwise put in gimbal
if( $mode == 2 ){
manipRotateContext -e -mode 1 Rotate; //world
}else{
manipRotateContext -e -mode 2 Rotate; //gimbal
}
}
A couple other tips for making deformations. --Using smooth mode with all but two influences locked to get fleshy areas working better after some preliminary weighting is done.
--Using move skin joint tool to experiment with better joint positioning
--Using a plane to figure out how to create joint chains to rotate okay, and also be on ok axis for ikhandle's etc to work well.
cheers,
Nate
Labels:
Mel Scripts
Tuesday, September 2, 2014
Tip: scripting to help search rigging hierarchies
Hi,
Here is a handy little script i wrote today in Maya to help with selecting parents of selected things.
Hope you find it helpful.
I used this by isolating some finger controls, working out their orientations and grouping via script, then i wanted to unparent the curves group parents back to the world. This was helpful with that. (side tip: isolate select is really helpful to have simpler work area to work with during rigging)
Cheers,
Nate
Here is a handy little script i wrote today in Maya to help with selecting parents of selected things.
Hope you find it helpful.
//select parent of each thing selected, expects a parent no error checking
string $icon[] = `ls -sl`; //no error checking
if(size($icon) > 0){
string $result[] = {};
for($arg in $icon){
string $grp[] = {};
$grp = `pickWalk -d up $arg`;
$result = stringArrayCatenate( $result, $grp );
}
select -r $result;
}
I used this by isolating some finger controls, working out their orientations and grouping via script, then i wanted to unparent the curves group parents back to the world. This was helpful with that. (side tip: isolate select is really helpful to have simpler work area to work with during rigging)
Cheers,
Nate
Labels:
Mel Scripts
Monday, September 1, 2014
Some scripts to help build rigging fk controls
Hi,
Here are a couple of short tools i wrote to help build fk controls during rigging. Hope you find this helpful.
cheers,
Nate
Inspired by Michael Comet (comet-cartoons dot com) Check out his amazing tools that are incredibly helpful for rigging.
Here are a couple of short tools i wrote to help build fk controls during rigging. Hope you find this helpful.
//treat like selecting target then base shape, icon, then destination jnt
//it puts control at destination, freezes its transformations, groups it with same name, you need to then unparent it to world
string $sel[] = `ls -sl`;
{
if(size($sel) == 2){
//no error checking
string $curve = $sel[0];
string $joint = $sel[1];
delete(`pointConstraint -offset 0 0 0 -weight 1 $joint $curve`);
parent $curve $joint;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $curve; //freeze transformations
string $ctrlPar = `group $curve`;
rename $ctrlPar ($curve+"_grp");//assumes we want to rename it
}
}
//select cvs of all selected curves
string $curve[] = `ls -sl`; //no error checking
string $result[] = {};
for($arg in $curve){
select -r $arg;
selectCurveCV all;//no error checking
$result = stringArrayCatenate( $result, `ls -sl` );
}
select -r $result;
//make world null group on selected using default suffix
{
string $sel[] = `ls -sl`;
for($arg in $sel){
string $ctrlPar = `group $arg`;//should default world axis at origin
rename $ctrlPar ($arg+"_par_grp");//assumes we want to rename it
}
}
cheers,
Nate
Inspired by Michael Comet (comet-cartoons dot com) Check out his amazing tools that are incredibly helpful for rigging.
Labels:
Mel Scripts
Wednesday, August 13, 2014
Some Maya scripting hints
Hi,
Hope you enjoy some of these scripting hints i wrote.
using wild card selection ex: to possibly remove skinned joints for face rigging
cheers,
Nate
Hope you enjoy some of these scripting hints i wrote.
using wild card selection ex: to possibly remove skinned joints for face rigging
//select skinned joints, helpful to remove, does not support actually checking skin clusters
//assumes skin is in name of bound joints
global proc na_selectSkin(string $faceArea){
//ex: select all eye skin joints select "*eye*skin*";
select "*"+$faceArea+"*skin*";
select -r `ls -sl -type joint`; //need this so dealing with joints only
}
print("run this --\n"+"na_selectSkin(\"eye\")");
having animation graph editor be opened automatically, example seeing set driven key curve for face blendshapes for modification//author: Nathaniel Anozie (ogbonnawork at gmail dot com)
//
//
//modify at own risk
// updated 08-13-2014 nate ----- initial commit
global proc na_showBSCurve( string $object[] ){
//show blendshape curve given object hooked up to it
//object -- animator control
if(size($object) >= 1){
string $result[] = {};
//assumes straight forward to get input from animator control
for($arg in $object){
string $curves[] = {};
$curves = `listConnections -plugs true -destination true -source false $arg`;
$result = stringArrayCatenate($result,$curves);
}
//show graph of set driven key for editing
select -r $result;
GraphEditor;
FrameSelected;
fitPanel -selected;
}
else{print("Please select object hooked up to blendshape");}
}
//usage
//show blendshape node sdk curve for editing given a selected object hooked up to it
eval( "source \"na_showBSCurve.mel\";" );
string $sel[] = {};
$sel = `ls -sl`;
na_showBSCurve($sel);
ability to quickly select all input of an object ex: easy export of selection including materials etc(before and after script)
#select all history and materials of selected, helpful for exporting in Maya
#author: Nathaniel Anozie (ogbonnawork at gmail dot com)
#
#
#Inspired by Alex Martelli, learning about expand list of lists in python from his online tutorials
#Inspired by Irakli Khakhviashvili, learning about selecting shaders from his online tutorials
#Inspired by Patrick Westerhoff, learning about list uniqueness in python from his online tutorials
#modify at own risk
# updated 08-13-2014 nate ----- initial commit
import maya.cmds as cmds
def na_niceSelect():
"""
select all history and materials of selected, helpful for exporting in Maya
"""
result = []
sel = cmds.ls(selection = True)
print "start --- calculating"
tmpResult = []
for _arg in sel:
tmpResult.append( _arg )#important to have everything in lists
#ex 'openJaw1:new_topology53'
#compute past
past = []
past = cmds.listHistory(_arg)
for _past in past:
tmpResult.append(_past)
#if its a mesh also adds its materials
shader = []
shader = cmds.listConnections( _past, type = "shadingEngine")
if shader is not None:
tmpResult.append( shader )
print "done --- calculating"
#
#concluding
#result = [item for sublist in tmpResult for item in sublist]
#result = list(set(result)) #remove possible duplicates
#cmds.select(result, replace = True, ne = True) #selecting results
#selecting
cmds.select(clear = True)
for _result in tmpResult:
cmds.select(_result, add = True, ne = True) #ne is so can select shaders
result = cmds.ls(selection = True)
return result
Hope this was helpful.
cheers,
Nate
Labels:
Mel Scripts,
Python Scripts
Friday, August 8, 2014
Tip: control region of stretching via squash deformer and blendweight painting
Hi
I was thinking about adding some squash to a face rig project im working on in Maya, so i decided to do a quick test to see one approach of adding squashing to a region of mesh (like upperhead, lower head).
made two copies of sphere
for first sphere put the squash deformer on
selected verts of region want then make squash deformer
now plug first sphere into second as blendshape
in blendweight editor use replace/smooth tools to flood weights to get a smooth falloff.
Now could potentially build editable blendshapes from these starting results.
(for the control part i used a locator translate y and plugged it into factor of squash deformer)
Hope this is helpful,
Cheers,
Nate
Here's a helpful MEL script i wrote to put -1, 1 limit on translate y of selected objects, could tweak for other channels etc.
I was thinking about adding some squash to a face rig project im working on in Maya, so i decided to do a quick test to see one approach of adding squashing to a region of mesh (like upperhead, lower head).
made two copies of sphere
for first sphere put the squash deformer on
selected verts of region want then make squash deformer
now plug first sphere into second as blendshape
in blendweight editor use replace/smooth tools to flood weights to get a smooth falloff.
Now could potentially build editable blendshapes from these starting results.
(for the control part i used a locator translate y and plugged it into factor of squash deformer)
Hope this is helpful,
Cheers,
Nate
Here's a helpful MEL script i wrote to put -1, 1 limit on translate y of selected objects, could tweak for other channels etc.
//make limits of y between -1 and 1
for($arg in `ls -sl`){
transformLimits -ty -1 1 -ety 1 0 $arg;
transformLimits -ty -1 1 -ety 1 1 $arg;
};
Inspired by,
Jason Schleifer (jasonschleifer dot com) (i first learned about squash deformer and doing rigging toolkit tests from reading his Animator Friendly Rigging course)
Labels:
doodles,
Mel Scripts
Wednesday, August 6, 2014
Call MEL with return in Python
Hi,
Hope this is helpful.
(Note its probably cleaner to write all the code in Python)
cheers,
Nate
Hope this is helpful.
//MEL
global proc string[] nozo(string $a, string$b ){
return {$a,$b};
}
//nozo("great","day")
#Python import maya.mel as mel #calling a Mel function in python cmd = "nozo" arg1 = '"Great"' arg2 = '"Day"' melCallString = "%s(%s,%s)" %(cmd,arg1,arg2) print melCallString ##### result = mel.eval(melCallString) print result #['Great', 'Day']
(Note its probably cleaner to write all the code in Python)
cheers,
Nate
Labels:
Mel Scripts,
Python Scripts
Friday, July 18, 2014
Create Icon text (MEL)
Hi,
Hope this is helpful to quickly create selectable text in Maya (put the text in quotes after the -t argument):
examples:
Also i'm thinking of writing a hotkey/short script that adds whatever selected (edges,faces, poly ..) to the current items in view--isolate. This way can work on inner mouth and eye topology areas and get extruded results added to the isolated viewed items quickly.
cheers,
Nate
Hope this is helpful to quickly create selectable text in Maya (put the text in quotes after the -t argument):
examples:
textCurves -ch 0 -f "Arial-Regular" -t "roll"; textCurves -ch 0 -f "Arial-Regular" -t "cheek"; textCurves -ch 0 -f "Arial-Regular" -t "narrow";
Also i'm thinking of writing a hotkey/short script that adds whatever selected (edges,faces, poly ..) to the current items in view--isolate. This way can work on inner mouth and eye topology areas and get extruded results added to the isolated viewed items quickly.
cheers,
Nate
Labels:
Mel Scripts
Thursday, July 17, 2014
Toggle front and side camera (MEL)
Hi,
When i was modeling facial blendshapes i wanted a quick way to see how the shapes were working in the front and side views so i wrote a Maya hotkey to toggle between the front and side camera. Hope you find this helpful.
Nate
Inspired by Bryan Ewert's online tutorial on querying camera of a panel
When i was modeling facial blendshapes i wanted a quick way to see how the shapes were working in the front and side views so i wrote a Maya hotkey to toggle between the front and side camera. Hope you find this helpful.
//toggle front and side of active panel
string $window = `getPanel -withFocus`;//example modelPanel1
if( `modelEditor -q -camera $window` == "side" ){
lookThroughModelPanel front $window;
}
else{
lookThroughModelPanel side $window;
}
cheers,
Nate
Inspired by Bryan Ewert's online tutorial on querying camera of a panel
Labels:
Mel Scripts
Monday, July 14, 2014
Tip: Update Blendshape and keep its blendnode connections
Hi,
Tip updating a blendshape and keeping all its driven keys, connections etc.
(note for cleanup it does need a little work with nodes example disconnecting shape inmesh from blend node -- (i wrote a test script to clean up a meshes input its still a work in progress but may be helpful))
Suppose wanted to change l_brow_up with a new sculpt but its already connected up with a ui etc. To update it with say new_l_brow_up, just plug new_l_brow_up into l_brow_up as a blendshape and put blendweight at 1. Then just delete new_l_brow_up. Now our l_brow_up should be updated with change and how its used with a blend node is preserved.
Here's the rough script i wrote to clean up a meshes input:
Hope you find this helpful.
cheers,
Nate
Tip updating a blendshape and keeping all its driven keys, connections etc.
(note for cleanup it does need a little work with nodes example disconnecting shape inmesh from blend node -- (i wrote a test script to clean up a meshes input its still a work in progress but may be helpful))
Suppose wanted to change l_brow_up with a new sculpt but its already connected up with a ui etc. To update it with say new_l_brow_up, just plug new_l_brow_up into l_brow_up as a blendshape and put blendweight at 1. Then just delete new_l_brow_up. Now our l_brow_up should be updated with change and how its used with a blend node is preserved.
Here's the rough script i wrote to clean up a meshes input:
//07-14-2014 -- nate -- initial release
//Modify at own risk
global proc na_cleanBlendshapeInput(){
//clean blendshape input of selected, currently it assumes preserving shader on blendshape is not required
//assumes shape selected assumes shape has exactly one blend node
if(size(`ls -sl`) == 1){
string $selAr[] = `ls -sl`;
string $shape = "";
//so it can work with selecting transform or shape
if( `objectType $selAr[0]` != "mesh" ){
string $tryThisAr[] = `pickWalk -d down`;//ignoring if doesnt have shape
if( `objectType $tryThisAr[0]` == "mesh"){$shape = $tryThisAr[0];}
else{error("Requires single Shape selected");}
}
else{$shape = $selAr[0];}
//
string $allHistory[] = `listHistory $shape`;
string $blendNodeAr[] = `ls -type blendShape $allHistory`;
if(size($blendNodeAr) == 1){
string $blendNode = $blendNodeAr[0];
//cleanup blendshape input
//disconnectAttr lipBlend_test2.outputGeometry[0] |r_brow_up_default|r_brow_up_defaultShape.inMesh;
disconnectAttr ($blendNode+"."+"outputGeometry[0]") ($shape+"."+"inMesh");
//remove blend node for cleanup this need to come after disconnecting
//might need to verify this blendnode is coming from input only
delete $blendNode;
}
else{error("Requires one blend shape node on selected shape!!!");}
}
}
Hope you find this helpful.
cheers,
Nate
Labels:
doodles,
Mel Scripts
Thursday, July 3, 2014
Smooth Toggle and Duplicate Skinned Mesh Mel scripts
Hi,
As i was working on sculpting facial shapes of a character and i wanted to duplicate the skinned mesh i found it a little time consuming each time unlocking all the translate and rotate channels so i wrote a short Mel script to do this, it requires first selecting the mesh we wish to copy and then the default mesh, it creates a clean copy. (on a side note this may also be helpful making a clean mesh to export to ZBrush for further editing.
Also as i was working i found it a little time consuming having to switch divisions of a smoothed mesh (polyFaceSmooth) to 0 each time i wanted to make a duplicate. So i wrote a short Mel script that toggles between divisions quickly, it needs the shape selected so just select your mesh hit the down arrow then run script.
Hope they are helpful
cheers,
Nate
modify at your own risk:
As i was working on sculpting facial shapes of a character and i wanted to duplicate the skinned mesh i found it a little time consuming each time unlocking all the translate and rotate channels so i wrote a short Mel script to do this, it requires first selecting the mesh we wish to copy and then the default mesh, it creates a clean copy. (on a side note this may also be helpful making a clean mesh to export to ZBrush for further editing.
Also as i was working i found it a little time consuming having to switch divisions of a smoothed mesh (polyFaceSmooth) to 0 each time i wanted to make a duplicate. So i wrote a short Mel script that toggles between divisions quickly, it needs the shape selected so just select your mesh hit the down arrow then run script.
Hope they are helpful
cheers,
Nate
modify at your own risk:
global proc string[] na_duplicateSelectedUsingDefaultMesh(){
//so we have a clean version to start sculpting correctives etc
//requires first selecting single blendshape then base mesh
string $defaultArg, $default;
string $blendArg, $blend;
string $defaultAr[], $blendAr[];
if(size(`ls -sl`) == 2){
string $sel[] = `ls -sl`;
$blendArg = $sel[0];
$defaultArg = $sel[1];
}
else{error("Select Blendshape then Default Mesh!!!");}
//so not stepping over any work
string $defaultAr[] = `duplicate -rr $defaultArg`;
$default = $defaultAr[0];
string $blendAr[] = `duplicate -rr $blendArg`;
$blend = $blendAr[0];
//make a clean version it uses default settings of first thing selected
select -r $blend;
select -add $default;
string $blendNameAr[] = `blendShape`;
setAttr ($blendNameAr[0]+"."+$blend) 1;
//cleanup and return result
string $resultAr[] = `duplicate -rr $default`;
string $result = $resultAr[0];
delete(`pointConstraint -offset 0 0 0 -weight 1 $blend $result`);
delete $default;//only deleting copies so not messing up scene
delete $blend;
//end cleanup
//could return result here
return $resultAr;
}
na_duplicateSelectedUsingDefaultMesh();
//07-03-2014 -- 07-07-2014 -- added support selecting transform, fixed a finding smooth node bug
global proc na_toggleSmoothOnShape(){
//Toggle smooth division of selected between none and smooth
//assumes shape selected assumes shape has exactly one smooth node
if(size(`ls -sl`) == 1){
string $selAr[] = `ls -sl`;
string $shape = "";
//so it can work with selecting transform or shape
if( `objectType $selAr[0]` != "mesh" ){
string $tryThisAr[] = `pickWalk -d down`;//ignoring if doesnt have shape
if( `objectType $tryThisAr[0]` == "mesh"){$shape = $tryThisAr[0];}
else{error("Requires single Shape selected");}
}
else{$shape = $selAr[0];}
//
string $allHistory[] = `listHistory $shape`;
string $smoothNodeAr[] = `ls -type polySmoothFace $allHistory`;
if(size($smoothNodeAr) == 1){
string $smoothNode = $smoothNodeAr[0];
//toggle between 0 and 2 divisions
int $currentDivision = getAttr ($smoothNode+".divisions");
if($currentDivision != 0){setAttr ($smoothNode+".divisions") 0;}
else{setAttr ($smoothNode+".divisions") 2;}
}else{error("Requires one polySmoothFace on selected shape!!!");}
}
}
na_toggleSmoothOnShape();
Labels:
Mel Scripts
Wednesday, July 2, 2014
Tool idea correcting scale when exporting ZBrush blendshape to Maya (III)
Hi,
Here's a working version of the script.
Basically just need to select zbrush blendshapes in maya scene, then type in the maya default name and zbrush default name in the function call, the result correct shapes should have a suffix on them like "_naScaled"
Here's the MEL version i wrote:
Hope this is helpful.
cheers,
Nate
Here's a working version of the script.
Basically just need to select zbrush blendshapes in maya scene, then type in the maya default name and zbrush default name in the function call, the result correct shapes should have a suffix on them like "_naScaled"
Here's the MEL version i wrote:
// updated 07-02-2014 nate ----- working on initial commit
//--------------------------------------
//requires "to recreate blendshapes" selected on scene, input is "maya default mesh", and the "zbrush default mesh".
//also the zbrush default mesh and the zbrush blendshapes need to be of identical scaling, i exported a non deformed one from zbrush after if needed subdivisions
//--------------------------------------
global proc zbrushBlendshapeToMaya(string $mayaDefaultArg, string $zbrushDefaultArg )
{
string $mayaDefault, $zbrushDefault;
//$zbrushDefault = "polySurface217";
//$mayaDefault = "polySurface216";
string $mayaDefaultAr[] = {};
//weve got input -- maybe set visibility of originals off, maybe unlock all translate channels of duplicates
$mayaDefaultAr = `duplicate -rr $mayaDefaultArg`;
$mayaDefault = $mayaDefaultAr[0];
string $zbrushDefaultAr[] = {};
$zbrushDefaultAr = `duplicate -rr $zbrushDefaultArg`;
$zbrushDefault = $zbrushDefaultAr[0];
delete -ch $mayaDefault;//clean history
delete -ch $zbrushDefault;//clean history
//
//weve checked selected blendshapes
string $sectionShapesArray[] = {};
string $sectionShapes = "";
//$sectionShapes = {"lt_browLowerer","lt_innerBrowRaiser","lt_outerBrowRaiser"};
$sectionShapesArray = `ls -sl`;
if(size($sectionShapesArray) == 0){error("First Select blendshape(s) !!!. \ninput should NOT be deformed !!! \n");}
//
//make a polygon that will be used to offset and correct zbrush blendshapes to make them scaled like maya default mesh
string $meshCombineName = "";
select -r $zbrushDefault;
select -add $mayaDefault;
string $meshCombineblendNameAr[] = `blendShape`; //make sure blendnode not on scene
$meshCombineblendName = $meshCombineblendNameAr[0];
//---make zbrush default move maya default, both need to have identical topology and be in default position
setAttr ($meshCombineblendName+"."+$zbrushDefault) 1;
string $meshCombineNameAr[] = {};
$meshCombineNameAr = `duplicate -rr $mayaDefault`;
$meshCombineName = $meshCombineNameAr[0];
//--so mayaDefault back to original so we can use it again
setAttr ($meshCombineblendName+"."+$zbrushDefault) 0;
delete -ch $mayaDefault;//clean history
//done making the offset polygon//
//start correcting zbrush blendshapes
for( $sectionShapes in $sectionShapesArray ){
//so we start with clean mesh to use
string $mayaDefaultTempAr[] = `duplicate -rr $mayaDefault`;
$mayaDefaultTemp = $mayaDefaultTempAr[0];
//make shape and "created poly" move default mesh
select -r $sectionShapes $meshCombineName;
select -add $mayaDefaultTemp;
string $blendNameAr[] = `blendShape`; //make sure blendnode not on scene
$blendName = $blendNameAr[0];
//---do operate math to make result
setAttr ($blendName+"."+$sectionShapes) 1;
setAttr ($blendName+"."+$meshCombineName) -1;
//do saving and cleanup
$resultShapeName = $sectionShapes+"_naScaled";
duplicate -n $resultShapeName -rr $mayaDefaultTemp;
delete $mayaDefaultTemp;//remove unneeded mesh,may want to delete history first not sure
delete(`pointConstraint -offset 0 0 0 -weight 1 $sectionShapes $resultShapeName`); //clean position of created shape
}//end looping over all selected shapes
//final cleanup
delete $meshCombineName;
delete $mayaDefault;
delete $zbrushDefault;
}
Hope this is helpful.
cheers,
Nate
Labels:
Mel Scripts
Tuesday, June 24, 2014
Make secondary rigs faster using MEL
Hi,
I ran into a situation where i wanted to add joints to the lips and eyes to allow offset controls but it was taking some time orienting each joint to glide along the surface and then repeatedly zeroing out rotates then doing a reparenting to zero out translates.
Here are a couple lines of MEL that may be helpful doing this automatically. Both assume you have already rotate joints how you want them to move on surface.
1. select joints then in MEL script editor type
2. select all joints then type:
(it makes duplicate of each thing selected and parent to each thing selected)
Hope you find this helpful
cheers,
Nate
I ran into a situation where i wanted to add joints to the lips and eyes to allow offset controls but it was taking some time orienting each joint to glide along the surface and then repeatedly zeroing out rotates then doing a reparenting to zero out translates.
Here are a couple lines of MEL that may be helpful doing this automatically. Both assume you have already rotate joints how you want them to move on surface.
1. select joints then in MEL script editor type
makeIdentity -apply true -t 0 -r 1 -s 0 -n 0;
2. select all joints then type:
(it makes duplicate of each thing selected and parent to each thing selected)
//assumes no issues finding joint on scene
string $sel[] = `ls -sl`;
for($arg in $sel){
//string $arg = "lip_all";
string $dup_ar[] = `duplicate -rr $arg`;
parent $dup_ar[0] $arg;
}
Hope you find this helpful
cheers,
Nate
Labels:
Mel Scripts
Thursday, June 12, 2014
Tool idea to reuse blendshapes after few topology changes II
Hi,
Here's the current version of the script i wrote in MEL. Its still a work in progress so I would suggest testing it on a test scene before any attempt at using it in production. Also there is no gui for the tool.
What is it for?
Say weve got lots of blendshapes in Maya made already and then we made some topology changes from the "old topology mesh" creating a "new topology mesh", this tool is one way to try to get all those blendshapes recreated using the new topology mesh.
To use it,
--source the MEL script,
--have a copy of the "old topology default mesh" This is the default mesh used to create the already made blendshapes.
--have a copy of the "new topology mesh" in its default pose.
Now select all the already made blendshape polygon meshes,
then type in MEL script editor:
facerigMakeSelSectionIntoFullBlendshape("PUT NAME new topology mesh", " PUT NAME old topology default mesh" )
(remove any unnessary base nodes tool made .. select "*Base" or something like that should be able to quickly remove them)
Now should have copies of all the old blendshapes but using the new topology. Notice may have some weird looking shapes especially for areas with major topology differences that would need to be corrected.
(ex: on the left is the tool created blendshape , on the right is the old blendshape )
Here it is:
Modify at your own risk.
Hope this is helpful,
cheers,
Nate
Here's the current version of the script i wrote in MEL. Its still a work in progress so I would suggest testing it on a test scene before any attempt at using it in production. Also there is no gui for the tool.
What is it for?
Say weve got lots of blendshapes in Maya made already and then we made some topology changes from the "old topology mesh" creating a "new topology mesh", this tool is one way to try to get all those blendshapes recreated using the new topology mesh.
To use it,
--source the MEL script,
--have a copy of the "old topology default mesh" This is the default mesh used to create the already made blendshapes.
--have a copy of the "new topology mesh" in its default pose.
Now select all the already made blendshape polygon meshes,
then type in MEL script editor:
facerigMakeSelSectionIntoFullBlendshape("PUT NAME new topology mesh", " PUT NAME old topology default mesh" )
(remove any unnessary base nodes tool made .. select "*Base" or something like that should be able to quickly remove them)
Now should have copies of all the old blendshapes but using the new topology. Notice may have some weird looking shapes especially for areas with major topology differences that would need to be corrected.
(ex: on the left is the tool created blendshape , on the right is the old blendshape )
Here it is:
Modify at your own risk.
// updated 03-11-2014 nate ----- making wrap mechanism more robust, added multiple shape support
// updated 05-27-2012 nate ----- initial commit
//--------------------------------------
//requires sections selected on scene, input is full shape, and the overlapping section shape. assumes section does not have blendshapes. if shape look off change wrap options max dist to 0.01
//--------------------------------------
global proc facerigMakeSelSectionIntoFullBlendshape(string $full, string $section )
{
string $full, $section;
string $sectionShapesArray[] = {};
string $sectionShapes = "";
//$section = "polySurface217";
//$full = "polySurface216";
//$sectionShapes = {"lt_browLowerer","lt_innerBrowRaiser","lt_outerBrowRaiser"};
$sectionShapesArray = `ls -sl`;
if(size($sectionShapesArray) == 0){error("First Select half sculpted blendshape(s) !!!. \nDefault section should NOT be deformed !!! \n");}
string $wrapName = "";
for( $sectionShapes in $sectionShapesArray ){
//section should move full face
select -cl;
select -r $full;
select -add $section;
//CreateWrap;
CreateWrap;
string $fullShapeArray[] = {};
$fullShapeArray = `pickWalk -direction down $full`;
select -cl;
string $fullShape = $fullShapeArray[0];//would bug out if multiple child shapes
string $wrapNameArray[] = {};
$wrapNameArray = stringArrayRemoveDuplicates( `listConnections -source true -type wrap ($fullShape)` );
if(size($wrapNameArray) != 1){error("Error Wrapping Geometry !!!:"+$sectionShapes);}
string $wrapName = $wrapNameArray[0];
//deformer -type wrap $full; //there is some maya bug using this
//so we're not affecting mirrored side
setAttr ($wrapName+"."+"maxDistance") 0.01; //make smaller so section moves smaller area of full head
//setAttr ($wrapName+"."+"inflType") 2; //make points since verts should overlap ... i think need api to do this
//make shapes moving section
select -r $sectionShapes;
select -add $section;
//$blendName = "tmp_bnd";
string $blendNameAr[] = `blendShape`; //make sure blendnode not on scene
$blendName = $blendNameAr[0];
//---make section moving full face, section needs to be at default
setAttr ($blendName+"."+$sectionShapes) 0;
//select -r polySurface216 ;
//select -add polySurface217 ;
//deformer -type wrap polySurface216;
//--get our full faces
string $resultShapeName = $sectionShapes+"_full";
setAttr ($blendName+"."+$sectionShapes) 0;//first reset all shapes
setAttr ($blendName+"."+$sectionShapes) 1.0;
duplicate -n $resultShapeName -rr $full;
setAttr ($blendName+"."+$sectionShapes) 0;//put back to default
delete -ch $full;//clean history
delete -ch $section;//clean history
delete(`pointConstraint -offset 0 0 0 -weight 1 $sectionShapes $resultShapeName`); //clean position of created shape
}//end looping over all selected shapes
}
Hope this is helpful,
cheers,
Nate
Labels:
Mel Scripts
Friday, April 4, 2014
Using scripting in Maya to help with selecting things
Happy Friday,
Here's a script i wrote today to help make selections in Maya. I used this to add a prefix to all transforms and joints in a group.
Hope you find this script helpful:
//MEL
//prepare selection for renaming -- default uses entire hierarchy of single thing selected
if(size(`ls -sl`) == 1){
select -hierarchy;
select -r `ls -sl -type transform -type joint`;//only select transforms and joints
}
#Python
import maya.cmds as cmds
sel = []
if len( cmds.ls( selection = True ) ) == 1:
cmds.select(hierarchy = True)
sel = cmds.ls( selection = True , type = ["transform","joint"] )
cmds.select( sel, replace = True)
It is very helpful to use this in conjunction with Michael Comet's amazing rename tool to add prefixes on his website at (comet-cartoons dot com)
cheers,
-Nate
Inspired by
Michael Comet (comet-cartoons dot com).
Here's a script i wrote today to help make selections in Maya. I used this to add a prefix to all transforms and joints in a group.
Hope you find this script helpful:
//MEL
//prepare selection for renaming -- default uses entire hierarchy of single thing selected
if(size(`ls -sl`) == 1){
select -hierarchy;
select -r `ls -sl -type transform -type joint`;//only select transforms and joints
}
#Python
import maya.cmds as cmds
sel = []
if len( cmds.ls( selection = True ) ) == 1:
cmds.select(hierarchy = True)
sel = cmds.ls( selection = True , type = ["transform","joint"] )
cmds.select( sel, replace = True)
It is very helpful to use this in conjunction with Michael Comet's amazing rename tool to add prefixes on his website at (comet-cartoons dot com)
cheers,
-Nate
Inspired by
Michael Comet (comet-cartoons dot com).
Labels:
Mel Scripts
Wednesday, March 19, 2014
Tip: Using Hotkeys for Maya Rigging
Happy Wednesday,
Here are a couple hot keys I wrote for Maya (mel) that i've found useful for rigging, (especially the reveal selected in outliner one).
Hope this is helpful,
cheers,
-Nate
Here are a couple hot keys I wrote for Maya (mel) that i've found useful for rigging, (especially the reveal selected in outliner one).
//Reveal selected in outliner ---
outlinerEditor -e -sc 1 outlinerPanel1;
//template locators --
eval("select `ls -type locator`;\n toggle -state on -template");
//untemplate all locators --
eval("select `ls -type locator`;\n toggle -state off -template");
//toggle on off nurbs curves --
int $mode = `modelEditor -q -nurbsCurves modelPanel4`;
int $toggleMode = 1-$mode;
modelEditor -e -nurbsCurves $toggleMode modelPanel4;
//toggle on off joints --
string $window = `getPanel -withFocus`;
int $mode = `modelEditor -q -joints $window`;
//why 1 minus is so we can use one hot key to toggle both
modelEditor -e -joints (1-$mode) $window;
Hope this is helpful,
cheers,
-Nate
Labels:
Mel Scripts
Friday, March 7, 2014
Tip: MEL to select joints useful for skeleton binding
Happy Friday,
I found it helpful to use scripting to deselect joints we don't want to bind to our character.
Example if all the end joints have a name with suffix "_end" we can do something like this after we select all joints in hierarchy.
//in MEL script editor
select -tgl "*_end" //deselects all end joints from all the things currently selected
It may be helpful in skinning to select all joints from the selected root... Here is a short MEL script i wrote to do that .. (it also works if say wanted to select all arm joints just need to select the shoulder of each arm then run the script to select all the joints)
global proc na_selJointInHierarchyFromSelectedRoot(){
//---select all joints in hierarchy of selected root
string $sel[] = `ls -sl`;
if(size($sel) == 1){
select -hierarchy; select -r `ls -sl -type joint`;
}
else{
warning("Treating Each thing selected as a Root !!!\n");
//error("Requires a single selected root !!!\n");
string $addToSel[] = {};
for($arg in $sel){
select -r $arg;
select -hierarchy; select -r `ls -sl -type joint`;
$addToSel = stringArrayCatenate($addToSel, `ls -sl`);
select -cl;
}
$addToSel = stringArrayRemoveDuplicates($addToSel);
select -r $addToSel;
}
}
na_selJointInHierarchyFromSelectedRoot();
Hope you find this helpful.
cheers,
-Nate
Inspired by
Carlo Sansonetti (carlosansonetti dot com)
I found it helpful to use scripting to deselect joints we don't want to bind to our character.
Example if all the end joints have a name with suffix "_end" we can do something like this after we select all joints in hierarchy.
//in MEL script editor
select -tgl "*_end" //deselects all end joints from all the things currently selected
It may be helpful in skinning to select all joints from the selected root... Here is a short MEL script i wrote to do that .. (it also works if say wanted to select all arm joints just need to select the shoulder of each arm then run the script to select all the joints)
global proc na_selJointInHierarchyFromSelectedRoot(){
//---select all joints in hierarchy of selected root
string $sel[] = `ls -sl`;
if(size($sel) == 1){
select -hierarchy; select -r `ls -sl -type joint`;
}
else{
warning("Treating Each thing selected as a Root !!!\n");
//error("Requires a single selected root !!!\n");
string $addToSel[] = {};
for($arg in $sel){
select -r $arg;
select -hierarchy; select -r `ls -sl -type joint`;
$addToSel = stringArrayCatenate($addToSel, `ls -sl`);
select -cl;
}
$addToSel = stringArrayRemoveDuplicates($addToSel);
select -r $addToSel;
}
}
na_selJointInHierarchyFromSelectedRoot();
Hope you find this helpful.
cheers,
-Nate
Inspired by
Carlo Sansonetti (carlosansonetti dot com)
Labels:
doodles,
Mel Scripts
Subscribe to:
Posts (Atom)








