sunnuntai 15. helmikuuta 2015

Maya MEL: Custom shortcut - extrude with a specific div level

I was making a ribcage in Maya and I felt like my workflow could be improved, so I wrote a little script and assigned it a custom shortcut. I had a spine model and the ribs were spine faces extruded along a curve. Every time I extruded, after extruding I had to go back and change the amount of divisions on the extrusion to make the added part usable. The script I wrote does that automatically.

After the fact I realized that I can achieve the same effect by just changing the amount of divisions in the extrude settings. Thus, all this is mostly waste of time and might even be harmful as the script is not very well-behaved and pollutes the global namespace. Also, it is untested on wrong number or type of selections, so it might break things. I guess it still was a good little exercise and I'm documenting it to not repeat the same mistake. Please do not use this for anything, just learn from my experience.

The custom shortcut was created by going to Window > Settings/Preferences > Hotkey Editor, creating a new hotkey under 'User' and pasting the code there. Usage: first select face to extrude, then curve to extrude along and then Ctrl+Shift+N to extrude. The amount of division is set in $divs and is 30 in my case. Pic and code below.


int $divs = 30;

string $selection[] = `ls -selection -long`;
string $object;
string $tokenized[];
string $extrudeInputs[] = {};
for ( $object in $selection ) {
    tokenize $object "|" $tokenized;
    $extrudeInputs[ size($extrudeInputs) ] = ($tokenized[ size($tokenized)-1 ]);
}

print( "Extruding face '" + $extrudeInputs[0] + "' along curve '" + $extrudeInputs[1] + "' with " + $divs + " divisions.\n" );

polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -divisions $divs -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30 -inputCurve $extrudeInputs[1] $extrudeInputs[0];

1 kommentti:

  1. The Revlon Titanium Max Edition [Revlon's Titanium
    Tagged ion titanium on brassy hair "Revlon's Titanium Edition". Product titanium bolts Description. best titanium flat iron Description. SKU: Revlon Titanium Max. titanium build for kodi Price: $19.99. Availability: In stock. titanium nipple bars US: Availability

    VastaaPoista