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