Hey been working on a pivot tool for maya just so it makes it easier to put the pivot easier for common areas. I have that all up and running though where I'm running into a problem is putting the pivot on a selected vertex. I get the xform of the vertex but my problem is how would I split the selection array.
Example:
string $selection[] = `ls -sl`;
this prints for example pSphere1.vtx[300];
how would I terminate pSphere1.vtx[300] to just the object name unless theres a way I can get the name of the object another way? Would defintiely like to hear some other ways. I tried doing a string to string array but apparently mel will not let me do that
![:( :(](https://polycount.com/plugins/emojiextender/emoji/twitter/frown.png)
Looked a bit into the list command and saw there is a way to get all objects in the scene and the one that caught my eye was the tail flag so I might be able to use that to see what the last one selected was...on the bus home so gonna try that.
Replies
[php]
{
string selection[] = `ls -sl`;
string $selObject[] = `ls -o $selRequirement`;
print $selObject;
}
[/php]
technically you can actually have a component selected without being "hilite"-ed
and or have a hilite ed object without having a component or object/component selection of any kind.
Otherwise... n( and normally if not bulletproof )
$selection[] = `ls -hl`;
will return your pSphere1.vtx as pSphere1
PS The Mel code you have there, is $selRequirement just polygon as a string? Cause I looked through the doc and couldn't find anything besides just the flag by itself.
for example: a poly -sm 12 filterExpand will only return objects if an object is selected.
If using your pSphere1.vtx[300] selection as an example... nothing will be returned if that object is not in object mode.
filterExpand will return an array.. depending on your selection you may need to use the -expand "true" flag to assign every member it's own address.
filterExpand -sm 31 expand 0; will return poly.vtx[0:1]
whereas,
filterExpand -sm 31 expand 1; will return each to it's own addy ( poly.vtx[0] poly.vtx[1] )
depending on which version of Maya you have... I believe the latest versions of Maya will expand by default.
nope, I made 2 lazy copyPaste errors. It should have reflected yer code like:
{
string $selection[] = `ls -sl`;
string $selObject[] = `ls -o $selection`;
print $selObject;
}
Isn't setting a pivot on a vertex just a matter of holding d (pivot mode) and v (vertex snap) and middle clicking over the vertex you want?
string $vertName = "pSphere1.vtx[300]";
string $objName = `match "^[^\.]*" $vertName`;
print ($objName + "\n");
// prints "pSphere1"
The "match" and "tokenize" functions are really good for doing this sort of thing