Friday, 8 May 2026

renames stuff to black kites' naming conventions

 # =======================================================

# Maya Python Script

# Rename Selected Objects

# BaseName_0001_Suffix

#

# Example:

# SM_Chair_0001_GEO

# SM_Chair_0002_GEO

# SM_Chair_0003_GEO

#

# Automatically increments if names already exist

# =======================================================


import maya.cmds as cmds



# -------------------------------------------------------

# Find Next Available Number

# -------------------------------------------------------

def get_next_available_name(base_name, suffix):


    number = 1


    while True:


        # Format number as 4 digits

        number_str = str(number).zfill(4)


        # Build name

        new_name = "{}_{}_{}".format(

            base_name,

            number_str,

            suffix

        )


        # Check if object already exists

        if not cmds.objExists(new_name):

            return new_name


        number += 1



# -------------------------------------------------------

# Rename Logic

# -------------------------------------------------------

def rename_objects_execute(*args):


    # Get selected transforms

    sel = cmds.ls(selection=True, type="transform")


    if not sel:

        cmds.warning("Please select one or more transform nodes.")

        return


    # Get UI values

    base_name = cmds.textField(

        "baseNameField",

        q=True,

        text=True

    ).strip()


    suffix = cmds.textField(

        "suffixField",

        q=True,

        text=True

    ).strip()


    # Validation

    if not base_name:

        cmds.warning("Please enter a base name.")

        return


    if not suffix:

        cmds.warning("Please enter a suffix.")

        return


    renamed_count = 0


    # Rename all selected objects

    for obj in sel:


        # Get unique name

        new_name = get_next_available_name(

            base_name,

            suffix

        )


        # Rename

        renamed = cmds.rename(obj, new_name)


        print(

            'Renamed: {} -> {}'.format(obj, renamed)

        )


        renamed_count += 1


    print(

        "\nFinished. {} object(s) renamed.\n".format(

            renamed_count

        )

    )



# -------------------------------------------------------

# UI

# -------------------------------------------------------

def rename_tool_ui():


    window_name = "renameWithNumbersToolWin"


    # Delete existing window

    if cmds.window(window_name, exists=True):

        cmds.deleteUI(window_name)


    # Create window

    cmds.window(

        window_name,

        title="Rename With Incrementing Numbers",

        widthHeight=(420, 180)

    )


    cmds.columnLayout(

        adjustableColumn=True,

        rowSpacing=10

    )


    cmds.text(

        label="Rename Selected Transform Nodes"

    )


    cmds.separator(style="in")


    # Base name

    cmds.text(

        label="Base Name:",

        align="left"

    )


    cmds.textField("baseNameField")


    # Suffix

    cmds.text(

        label="Suffix:",

        align="left"

    )


    cmds.textField("suffixField")


    cmds.separator(style="in")


    # Execute button

    cmds.button(

        label="Rename Objects",

        height=40,

        command=rename_objects_execute

    )


    cmds.showWindow(window_name)



# -------------------------------------------------------

# Launch

# -------------------------------------------------------

rename_tool_ui()

python script to remove a string

insert string before string, Python script for Maya

generated through ChatGPT.. mel solutions seemed broken.
This will make a popup window, you put in your desired string and the one you want to put it in front of. Whatever you have selected gets processed

# =======================================================
# Maya Python Script
# Insert String BEFORE Another String
# on Multiple Selected Transform Nodes
# =======================================================

import maya.cmds as cmds


# -------------------------------------------------------
# Rename Logic
# -------------------------------------------------------
def insert_before_rename_execute(*args):

    # Get selected transforms
    sel = cmds.ls(selection=True, type="transform")

    if not sel:
        cmds.warning("Please select one or more transform nodes.")
        return

    # Get UI values
    insert_str = cmds.textField(
        "insertStringField",
        q=True,
        text=True
    )

    before_str = cmds.textField(
        "beforeStringField",
        q=True,
        text=True
    )

    # Validation
    if not before_str:
        cmds.warning("Please enter a target string.")
        return

    renamed_count = 0

    # Process all selected objects
    for obj in sel:

        # Skip objects that don't contain target string
        if before_str not in obj:
            print(
                'Skipped "{}" (target string not found)'.format(obj)
            )
            continue

        # Find insertion point
        index = obj.find(before_str)

        # Build new name
        new_name = (
            obj[:index] +
            insert_str +
            obj[index:]
        )

        # Rename object
        renamed = cmds.rename(obj, new_name)

        print(
            'Renamed: {} -> {}'.format(obj, renamed)
        )

        renamed_count += 1

    print(
        "\nFinished. {} object(s) renamed.\n".format(
            renamed_count
        )
    )


# -------------------------------------------------------
# UI
# -------------------------------------------------------
def insert_before_tool_ui():

    window_name = "insertBeforeToolWin"

    # Delete existing window
    if cmds.window(window_name, exists=True):
        cmds.deleteUI(window_name)

    # Create window
    cmds.window(
        window_name,
        title="Insert String Before",
        widthHeight=(400, 180)
    )

    cmds.columnLayout(
        adjustableColumn=True,
        rowSpacing=10
    )

    cmds.text(
        label="Rename Selected Transform Nodes"
    )

    cmds.separator(style="in")

    # Insert string
    cmds.text(
        label="String To Insert:",
        align="left"
    )

    cmds.textField("insertStringField")

    # Before string
    cmds.text(
        label="Insert BEFORE This String:",
        align="left"
    )

    cmds.textField("beforeStringField")

    cmds.separator(style="in")

    # Execute button
    cmds.button(
        label="Rename Selected Objects",
        height=40,
        command=insert_before_rename_execute
    )

    cmds.showWindow(window_name)


# -------------------------------------------------------
# Launch
# -------------------------------------------------------
insert_before_tool_ui()

Monday, 3 April 2023

Thursday, 16 March 2023

padding numbers in maya - mel

 python - Number/Version Paddings in Maya - Stack Overflow
don't know why I've never really had to do this before heh. Watch out for the backticks. The python bit really wants the ' and not the `, but then the mel bit really wants the `. sigh.
Also hilarious that you have to use a python function for this.

$padding = 3;
$num = 5;
string $pad = `python ("'%0"+$padding+"d' % "+$num)`;
// Results is: 005

Thursday, 9 March 2023

selecting with wildcards

Don't know why I always forget this, but here's a mel script to select things with wildcards...
select -r "ballShape*";

Monday, 27 February 2023

deleting uv sets maya

 Maya 2020 UV Sets infuriating - need help : Maya (reddit.com)

sometimes you need to kill uv maps, you have to move the one you want to delete so it isn't at the top of the list - it can only be moved if you use the UV Toolkit mode - right at the bottom of the tabs there'll be a UV Sets rollout that lets you do so & delete the offending sets. VERY SHITTY.



Friday, 24 February 2023

python way of making the bones based on cvs

from cgtalk forum poster - Darksuit

CGTalk | Auto-create joint chain along spline? (cgsociety.org)

just in case - 

changing the orientation on the joints should be easy enough look to the script for

this line

cmds.joint(currentJoint,e=True,zso=True,oj="xyz")

change the oj=“xyz” to the orientation you need… more than likely you are looking for “xzy”.

The import maya.cmds as cmds line imports the MEL script commands to python. There are some differences, but there is a lot of good documentation, and a number of references out there.

as for reorienting the joints. change the following line i=1 in the last block to i=0 that will start the orientation at the base joint instead of the second joint. A lot of times I leave the base joint aligned to world for my own uses.




 import maya.cmds as cmds


# array of selected objects

sel = cmds.ls( selection=True )


# name of the curve to convert

lastSelect = int(len(sel)) -1

curveSel = sel[lastSelect]


# print lastSelect

#print curveSel


#find the number of CVs (Degree + Spans)

numCVs = int(cmds.getAttr (curveSel+'.degree'))+ (cmds.getAttr (curveSel+'.spans'))

#print numCVs


# selection must be clear

cmds.select(clear=True)


#For each CV in the Curve create a joint.


i=0

while 1:

    if not ( i < numCVs ):

        break

    cvPosition = (cmds.getAttr (curveSel+'.cv['+(str(i))+']'))

    if (i == 0):

    cmds.joint(n=curveSel+'_jointRoot',p = cvPosition[0])

    if (i == (numCVs-1)):

    cmds.joint(n=curveSel+'_jointEnd', p = cvPosition[0])

    if(i>0)and(i != numCVs-1):

    cmds.joint(n=curveSel+'_joint_'+(str(i)),p = cvPosition[0])

    i+=1

 

# reorient the joints    

i=1

while 1:

if not (i < numCVs-1):

break

#find the name of the current Joint

currentJoint = (curveSel+'_joint_'+(str(i)))

cmds.joint(currentJoint,e=True,zso=True,oj="xyz")

i+=1


joints along curve script mel

 nnJointsOnCurve for Maya - Free Character Scripts / Plugins Downloads for Maya (highend3d.com)

JUST in case this vanishes... puts joints on a curve. v useful and simple

/////////////////////////////// nnJointsOnCurve /////////////////////////////////


//                              Scripted by -Nilesh Jadhav

//                                                         27-07-2010

/////////////////////////////////////////////////////////////////////////////////////

// -------------- This script generates joint chain on selected Curve ---------------

//////////////////////////////////////////////////////////////////////////////////////

//

////////////////////////// UI Designing for nnJointOnCurve /////////////////////////


if (`window -exists curveJoint`)

deleteUI "curveJoint";

    

    window -t "nnJointsOnCurve" -w 200 -h 200 -mnb 1 -mxb 0 -s 1 curveJoint;


columnLayout -adj 1 -columnAttach "both" 1 -rowSpacing 10 -columnWidth 250;


    intFieldGrp -l"Number of Joints" numberInt;

    checkBoxGrp -l"Rebuild the Curve" rebuildCheck;

    text -l "Select the Curve and press the Button" -fn "smallBoldLabelFont" ;

    button -l"<< Add Joint Chain on Curve >>" -h 30 -c ("nnJointsOnCurve()") goButton;

    text -l"Scripted by - Nilesh Jadhav" -bgc 1 1 1;


showWindow curveJoint;




/////////////////////////////////////  Procedure ////////////////////////////////////////////////


global proc nnJointsOnCurve()

{


    string $sel []=`ls -sl`;

    string $curve =$sel [0];

    string $check =`checkBoxGrp -q -v1 rebuildCheck`;

if ($check==1 )

{

rebuildCurve -rt 0 -s 25;


}

else

{

}

    string $lcr []=`spaceLocator`;

    string $loc =$lcr [0];


    string $path =`pathAnimation  -stu 1 -etu 1000 -f on  $curve $loc `; 

    int $numbers []=`intFieldGrp -q -v numberInt`;


    float $locPos []=`xform -q -ws  -t $loc`;

    int $divFacter =1000 / $numbers [0];


select -cl;

$i=`currentTime -q`;

            for ($i=1; $i<1000; $i=$i+$divFacter) //--------- Loop to make joint chain

                {




        currentTime $i;

        float $lcPos []=`xform -q  -ws -t locator1`;


        string $joints =`joint -a -p $lcPos [0] $lcPos [1] $lcPos [2]`;


}

string $selJoint []=`ls -sl`;

string $jnt =$selJoint [0]; 



    $i =1;

            for ( $i=1; $i<$numbers[0]+1; $i++) //--------- loop for getting 1st joint

                {

                    pickWalk -d up;

                }    

    

    joint -e -oj xyz -secondaryAxisOrient yup -ch -zso;



delete $path;

delete $loc;

currentTime -e 1;

}


Friday, 24 August 2018

UVs for a ribbon/pipe

1) Use the Unitize function to separate each face in the mesh and have them squarely fill the 0-1 UV space. 2) Select the edges where you want your seam. 3) Convert the selection to UV's. 4) Invert the selection. 5) Use the Move and Sew function. 6) Go in the option box for Unfold and select Vertical as your unfold constraint (horizontal if your UV's are oriented that way. 7) Enjoy your nice UV's.


https://www.youtube.com/watch?v=dahgVetfUZg

Saturday, 28 July 2018

simple sticky lips

http://www.kimonmatara.com/maya-easy-sticky-lips/
To begin, create two curves that will follow the contours of the upper and lower lips respectively as your rigged geometry deforms. These will be your ‘driver’ curves. There are various ways of doing this; in the example below, I merely drew the curves using snapping, and then wrapped them onto the original rig geometry:
Next, create a dynamic ‘averaged curve’ between them. To do this, follow these steps:
  1. Grab the curves’ shapes and graph them up in the Node Editor (or Hypershade, as you prefer).
  2. Create an ‘avgCurves’ node (in the Node Editor, you can hit tab and start typing ‘avgCurve’; alternatively, you could just issue a ‘createNode avgCurves’ in the MEL command line)
  3. Plug the ‘worldSpace’ output attribute of each curve shape into the inputCurve1 and inputCurve2 inputs of the avgCurve node:
  1. Back in the Outliner, duplicate one of the curves. This will be your ‘sticky’ curve.
  2. Add this curve’s shape to the Node Editor graph.
  3. Plug the ‘outputCurve’ output of the avgCurves node into the ‘create’ input of the curve:
  1. Select the avgCurves node and switch off ‘Automatic Weight’.
The resulting curve should fall right between the two lips, as thus:
Next, make a live, deforming copy of your rigged geometry. To do this, select your rigged geometry and issue ‘polyDuplicateAndConnect’ in the MEL command line. This will be your ‘sticky lips’ mesh. (This step is necessary to prevent dependency graph cycle problems.)
Now set the the averaged curve you created earlier as a wire deformer for this mesh. If in doubt as to how to do this, consult Maya’s documentation on the ‘wire’ deformer.
The wire deformer will have generated a ‘BaseWire’ curve. Select this curve’s shape in the Outliner and graph it in the Node Editor. Add the ‘avgCurve’ node you created originally to the graph.
Once again, plug the ‘outputCurve’ output of the avgCurve into the ‘create’ input of the BaseWire curve. We are doing this to cancel-out the wire deformer’s effects:
Paint-out the wire deformer’s influence to a narrow area along the inner lip edges:
Set ‘scale[0]’ on the wire deformer to 0.0, turn up the ‘dropoffDistance’ attribute, and overdrive ‘envelope’ to 2.0. Play with these settings until you get a good-looking result kicking in at the right range of motion.
You should now have something like the image below. If you turn up the wire dropoff, you’ll be able to zip-up the whole mouth, from the edges inwards.
  • The effect is distance-based, so some modest keying will be required in animation.

Wednesday, 18 April 2018

render layers in maya 2018

Render layers in 2018

Use groups in collections, this way you can easily swap out geo without having to update stuff each time someone changes something.

If a sub object needs changing, it could be worth putting that in a sub group too.

Use shader overrides rather than material overrides.

more UV crap

last post is a bit redundant in the age of UV-editing mode of Maya 2018, but with heavy meshes, the uv editor is dog slow.

polyEditUV -u 1 -v0 -scaleU 1.2 -scaleV 1;

Also this.

Monday, 16 April 2018

scaling UV code, around the centre of selection instead of 0,0

Original code stolen from
http://polycount.com/discussion/172364/maya-mel-scale-uv-shells-locally-script-for-anyone-that-wants-it


//store uvs into array
float $uvvalues[] =`polyEditUV -q`;
int $selSize = `size ($uvvalues)`;

//split array into U and V
float $Uarray[];
float $Varray[];

//copy U and V arrays with values
for($u = 0; $u < $selSize; $u++) {
          $Uarray[size($Uarray)] = $uvvalues[$u]; 
          $u=$u+1;
}

for($v = 1; $v < $selSize; $v++) {
          $Varray[size($Varray)] = $uvvalues[$v]; 
          $v=$v+1;
}

//sort arrays by coords and get size of array
$Uarray = `sort $Uarray`;
$Varray = `sort $Varray`;
int $UarraySize = `size ($Uarray)`;

//get max values
float $maxNuU = $Uarray[$UarraySize-1];
float $maxNuV = $Varray[$UarraySize-1];

//get min values
float $minNuU = $Uarray[0];
float $minNuV = $Varray[0];

//calculate centre values
float $middleU = ($maxNuU + $minNuU)/2;
float $middleV = ($maxNuV + $minNuV)/2;

polyEditUV -pu $middleU -pv $middleV -su .2 -sv .2;

Monday, 9 April 2018

some rapid rig specific scripts..sin waves on the leg/arm micro curves.

//used in Nike jelly legs

//CONTROLLER SETUP
//select controller for attributes to be added to, one by one. eg. left foot ctrl. then right.
string $footCtrl[]=`ls -sl`;

print $footCtrl[0];

//upper controls
addAttr -ln "o"  -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".o");
addAttr -ln "upper_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "upper_sinPhase"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_transY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_transZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoX"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];


//lower controls
addAttr -ln "oo"  -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oo");
addAttr -ln "lower_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "lower_sinPhase"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_transY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_transZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoX"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoY"  -keyable 1 -at double  -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoZ"  -keyable 1 -at double  -dv 0 $footCtrl[0];

//upper offsets
addAttr -ln "ooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".ooo");
addAttr -ln "upper_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];

//lower offsets
addAttr -ln "oooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oooo");
addAttr -ln "lower_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];


___________________________________________________________________________
//CONNECT CONTROLLER TO THE MICRO CURVES
//select the micro curves, can select them all, set the leftLeg and rightLeg strings!

string $ctrlNameSel[]=`ls -sl`;
print $ctrlNameSel[0];
float $ctrlOffset=0;
float $ctrlAmp=1;
string $leftLeg="abc_lLegSwitchC";
string $rightLeg="abc_rLegSwitchC";
string $ctrlUse="none";
string $region="none";

//looping
for ($ctrl in $ctrlNameSel){
   
    if(`gmatch $ctrl "*1C*"`){
    //top Node, set offsetVal
    $ctrlOffset=0;
    $ctrlAmp=0.55;
   
    }
    else if(`gmatch $ctrl "*2C*"`){
    //middle Node, set offsetVal
    $ctrlOffset=1.65;
    $ctrlAmp=1;
    }
    else if (`gmatch $ctrl "*3C*"`){
    //bottom Node, set offsetVal
    $ctrlOffset=2.2;
    $ctrlAmp=0.4;
    }
   
    //WHICH PART
    if(`gmatch $ctrl "*_rLower*"`){
    $ctrlUse=$rightLeg;
    $region="lower"; 
    }
    else if(`gmatch $ctrl "*_rUpper*"`){
    $ctrlUse=$rightLeg;
    $region="upper";
    }
    if(`gmatch $ctrl "*_lLower*"`){
    $ctrlUse=$leftLeg;
    $region="lower"; 
    }
    else if(`gmatch $ctrl "*_lUpper*"`){
    $ctrlUse=$leftLeg;
    $region="upper";
    }
   
   
    select $ctrl;
   
   
    string $newGroup=`group -name ($ctrl+"_sinGrp")`;

    string $offsetVal="float $offset="+$ctrlOffset+";\n";
    string $ctrlAmpStr="float $amp="+$ctrlAmp+";\n";
    //translate
   
    //string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY;\n";
    string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY * "+$ctrlUse+"."+$region+"_amp;\n";
   
   
    string $sinTZVal=$newGroup+".translateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_z_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transZ * "+$ctrlUse+"."+$region+"_amp;\n";
   
    string $sinRXVal=$newGroup+".rotateX=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_xRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoX * "+$ctrlUse+"."+$region+"_amp;\n";
    string $sinRYVal=$newGroup+".rotateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_yRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoY * "+$ctrlUse+"."+$region+"_amp;\n";
    string $sinRZVal=$newGroup+".rotateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_zRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoZ * "+$ctrlUse+"."+$region+"_amp;\n";
   
    string $expressionVal=$offsetVal + $ctrlAmpStr +$sinTYVal + $sinTZVal + $sinRXVal +$sinRYVal + $sinRZVal;
   
//   lower_xRot_sinOffset
   
    expression -s $expressionVal;
    select -cl;
}

______________________________________________________________________________
//REMOVE ATTRIBUTES FROM CONTROLLER
//select the controller (one by one)
//sets things to zero first, then deletes them

string $footCtrl[]=`ls -sl`;

print $footCtrl[0];

//remove upper controls, set to 0
setAttr -lock false ($footCtrl[0]+".o");
deleteAttr -at "o";


setAttr ($footCtrl[0]+".upper_amp") 0;
deleteAttr -at "upper_amp";

deleteAttr -at "upper_sinPhase";
deleteAttr -at "upper_transY";
deleteAttr -at "upper_transZ"; 
deleteAttr -at "upper_rotoX";
deleteAttr -at "upper_rotoY";  
deleteAttr -at "upper_rotoZ";


//lower controls
setAttr -lock false ($footCtrl[0]+".oo");
deleteAttr -at "oo";

setAttr ($footCtrl[0]+".lower_amp") 0;
deleteAttr -at "lower_amp"; 
deleteAttr -at "lower_sinPhase";
deleteAttr -at "lower_transY"; 
deleteAttr -at "lower_transZ"; 
deleteAttr -at "lower_rotoX";
deleteAttr -at "lower_rotoY";
deleteAttr -at "lower_rotoZ";  

//upper offsets
setAttr -lock false ($footCtrl[0]+".ooo");
deleteAttr -at "ooo";
deleteAttr -at "upper_y_sinOffset";
deleteAttr -at "upper_z_sinOffset";
deleteAttr -at "upper_xRot_sinOffset"; 
deleteAttr -at "upper_yRot_sinOffset";
deleteAttr -at "upper_zRot_sinOffset";

//lower offsets
setAttr -lock false ($footCtrl[0]+".oooo");
deleteAttr -at "oooo";
deleteAttr -at "lower_y_sinOffset";
deleteAttr -at "lower_z_sinOffset"; 
deleteAttr -at "lower_xRot_sinOffset"; 
deleteAttr -at "lower_yRot_sinOffset";
deleteAttr -at "lower_zRot_sinOffset";

__________________________________________________________________________
//DELETE SIN GROUPS FROM THE RIG
//just run it, no need to select (deletes all sin groups though)

string $ctrlSelected[]=`ls  "*_sinGrp*"`;

for($group in $ctrlSelected){
    select $group;
    print ($group+"\n");
    ungroup;
     
}

Tuesday, 13 March 2018

zbrush displacement map transfer etc.

Zbrush is still a pain. But a useful pain.
The situation is : Say you have a hi-res piece of geometry. You'd like to use a retopo'd low-res geo as a base mesh for subdivision and displacement. Mudbox doesn't really cut the mustard for this. And Maya's transfer map results are even more useless. Here's what you do.

  • Bring in your low-res UV'd geo to Zbrush. Turn it into a polytool so it sits in Zbrush's memory.
  • Now import your hi-res geo. It should replace everything in the scene
  • Go to the Subtool menu, select append and look for the polytool of the low-res geo you just created. Click it.
  • Hide the hi-res geo for the time being. 
  • In the Geometry menu, hit subdivide a bunch of times, to get enough hi-res detail. You probably don't need to go as high as the unoptimised hi-res geo.
  • Go back to the Subtool menu, show the hi-res geo again.
  • Click on the now-subdivided low-res geo and hit Project All. This is at the bottom of the Subtool menu.
  • Now your subdivided low-res geo should have taken on the detail from your hi-res geo.
  • Lower the subdivision level in the Geometry menu. Do the Project All again. Repeat for every lower level.
Now for the map generation bit

  • Set your low-res geo subdivision level to it's lowest setting. OR to whichever level you want to use as your base in Maya/Houdini/whatever.
  • In Z-Plugins, click Multimap Exporter and select the maps you'd like generating.
  • Make sure Flip V is ticked ON.
  • Make sure Smooth UVs is OFF.
  • Subdiv level should be at 1 or whichever level you've chosen.
  • For final map turn ON Adaptive.
  • Turn on 32bit EXR.
  • The rest is fine to leave as default. Scale should be 1. 
  • Click Export maps.
SHOULD WORK. DON'T HAVE MULTIPLE UV TILES. DON'T HAVE UV's ON THE EDGE OF A TILE. ZBRUSH IS STUPID AND WILL MESS UP YOUR BAKING.


Wednesday, 31 January 2018

NUKE - create UV map

Paste this to make a flat UV map, for distortion/undistortion grids etc

set cut_paste_input [stack 0]
Expression {
expr0 (x+0.5)/(width)
expr1 (y+0.5)/(height)
name Expression1
selected true
}



Saturday, 4 November 2017

moving specific Mash points

How to manually move points in MASH, using the python node..
Bold bits are the important lines of code, where 7 and 16 are the point numbers (add a Points node to see numbers). I'd assume you could hide specific points here too?



import openMASH

#initialise the MASH network data
md = openMASH.MASHData(thisNode)

#this is how to get the frame number
frame = md.getFrame()
#and this gets the number of objects in the network
count = md.count()

#add the index to the Y position
#for i in range(count):
#    md.outPosition[i].y=i

md.outPosition[7].y+=2;
md.outPosition[16].z+=3;
md.outVisibility[12]=0;
md.outRotation[12].x=12;

#tell MASH to write the network data
md.setData()


The docs say you can change -
  • outPosition
  • outScale
  • outRotation
  • outId
  • outVisibility

Wednesday, 7 June 2017

seem to use this a lot - set matte attr for arnold crap

string $selectedStuff[]=`ls -sl`;


int $sizeArray=size($selectedStuff);
for($i=0; $i<($sizeArray);$i++){
print $selectedStuff[$i];


setAttr ($selectedStuff[$i]+"Shape.aiMatte") 1;
//setAttr ($selectedStuff[$i]+".overrideLevelOfDetail") 1;
   
   
}

Wednesday, 1 March 2017

fix texture paths maya

https://mayapy.wordpress.com/2012/04/23/fix-texture-paths-in-maya-python-script/


import maya.cmds as cmds
import os

def renameTex(newName):
        tex=cmds.ls(sl=True,type="file")
for item in tex:
fullpath = cmds.getAttr("%s.fileTextureName" %item)
fileName= fullpath.split("/")[-1]
newPath= os.path.join(newName,fileName)
cmds.setAttr("%s.fileTextureName" %item, newPath,type="string")

def selectDir():
 folder=cmds.fileDialog2(cap="locate folder",fm=3)
 uniToStr=str(folder)

 filePath=uniToStr.split("'")[1]
 cmds.textField(pathText, edit=True,text=filePath)
 global newName
 newName=filePath

win=cmds.window(title="RV TEXTURE PATH FIX",w=350,h=150)
cmds.columnLayout(adjustableColumn=True )
cmds.text("FIRSTlect your file nodes in Hypershade!!",bgc=(1,0,0))
cmds.frameLayout(l="browse folder for textures")
cmds.flowLayout()
cmds.text("file",h=25)
pathText=cmds.textField(w=250,h=25)
loadBtn=cmds.button(w=50,h=25,label="get",c="selectDir()")

cmds.setParent( '..' )
fixit=cmds.button(l="Fix textures", c="renameTex(newName)")
cmds.setParent( '..' )

cmds.showWindow(win)