CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-05-2013, 08:13 PM   #1
Yosemany
New Member
portfolio
 
Join Date: Feb 2013
Posts: 15
'Fully' Selecting Vertices in MEL

Hi,

I'm new to MEL, so please go slowly.

I think my problem's quite simple. I often have a polygon edge selected, and I need to select each of the vertices on it (which is to say ANY of the vertices - once one is selected, I can use the arrow keys).

I have tried 'PolySelectConvert 3', 'polyListComponentConversion -tv' and 'ConvertSelectionToVertices' but these just make the vertices show up in yellow. I am not able to select them by clicking. I still have to right click for the masking menu, select 'Vertex', and then select them by clicking. I'm looking for a command or commands to help me speed it up a little.

Any help appreciated,

Joe
 
Old 02-08-2013, 11:08 AM   #2
depakeen
Veteran
portfolio
Jerome Pourcel
Paris, FR
 
Join Date: Sep 2011
Posts: 45
I'm not quite familiar with this operation, but it seems to work fine with me...
I tried two ways of doing that, whithout obvious problems:

Code:
string $actualSelection [] = `ls -sl`;//makes a list of the actual selection (selected edges) string $myConvertedVert [] = `polyListComponentConversion -tv $actualSelection`;//converts it to vertices in an array select -r $myConvertedVert;//selects the vertices



Code:
ConvertSelectionToVertices;//converts the actual selection in vertices //the operations below are for coding purposes only, in order to save the vertices list, //you can manipulate the selection in the viewports without them string $vertSelec [] = `ls -sl`;//lists the selected vertices as a concatenated list (it will look like : myObject.vtx[20:52]) string $allVertices [] = `filterExpand -sm 31`;//each vertex is now individual in this array (it will be now myObject.vtx[20] myObject.vtx[21], etc.}) print $allVertices;//shows what the array looks like
 
Old 02-08-2013, 12:43 PM   #3
Kobes
Veteran
portfolio
Jacob Santamaria
Melbourne, Australia
 
Join Date: Aug 2010
Posts: 70
Is the reason for this just to create a tool to convert your selection or is it part of something larger?

If you just want a way to do that maya does it for you. With your edge selected hold ctrl and RMB and it will show a range of conversion options, your looking for "To Vertices".

Sorry if you knew that already and just need the MEL workflow.

Cheers Jake
 
Old 02-08-2013, 01:25 PM   #4
Yosemany
New Member
portfolio
 
Join Date: Feb 2013
Posts: 15
Thanks for your replies deepakeen and Jake.

In the days after posting it, I worked out what the problem was. Because I am new to this forum, the anti-spam measures prevented the post from appearing until today (apparently my post had to be screened by an admin, which took three days) so I was unable to update it.

The commands I listed, better exemplified by deepakeen, DO convert the selection to vertices...however, because ALL vertices are selected the Move tool was responding as if my original edge was selected.

To get around that, I am now parsing the string returned by polyListComponentConversion. I am not sure if this is the 'best' way. My script is

string $buffer[];
string $vfList[];

// Get list of vertices contained in the current selection
$vfList = `polyListComponentConversion -tv -fe`;

for ($vf in $vfList) // If we have anything selected
{
// Split the string with the vertex coordinates
tokenize $vf ":" $buffer ;

// Correct the syntax on our new string by appending ']'
$buffer[0] = $buffer[0] + "]";

// Select the first vertex
select $buffer[0];
}
 
Old 02-08-2013, 02:26 PM   #5
thematt
brain filler
 
thematt's Avatar
matt
EMCA
France
 
Join Date: Mar 2003
Posts: 1,517
yes the marking menu or you could also use the shortcut that is create by default which is CTRL+F9
 
Old 02-08-2013, 03:15 PM   #6
rgkovach123
Know-it-All
robert
austin, USA
 
Join Date: Nov 2006
Posts: 364
selecting Vertices, and being able to select Vertices are actually two differnt things.

what you are missing is updating Maya's selection masks.

Maya is always in just one selection mode. This mode can be Multi-select, but usually it is either Object Mode, or Component+Component Mask mode.
 
Old 02-08-2013, 04:42 PM   #7
depakeen
Veteran
portfolio
Jerome Pourcel
Paris, FR
 
Join Date: Sep 2011
Posts: 45
Quote:
Originally Posted by Yosemany
Thanks for your replies deepakeen and Jake.

In the days after posting it, I worked out what the problem was. Because I am new to this forum, the anti-spam measures prevented the post from appearing until today (apparently my post had to be screened by an admin, which took three days) so I was unable to update it.

The commands I listed, better exemplified by deepakeen, DO convert the selection to vertices...however, because ALL vertices are selected the Move tool was responding as if my original edge was selected.

To get around that, I am now parsing the string returned by polyListComponentConversion. I am not sure if this is the 'best' way. My script is

string $buffer[];
string $vfList[];

// Get list of vertices contained in the current selection
$vfList = `polyListComponentConversion -tv -fe`;

for ($vf in $vfList) // If we have anything selected
{
// Split the string with the vertex coordinates
tokenize $vf ":" $buffer ;

// Correct the syntax on our new string by appending ']'
$buffer[0] = $buffer[0] + "]";

// Select the first vertex
select $buffer[0];
}


Here, you select a vertex at each iteration of the for loop, which is probably not what you want. Furthermore, you don't have to use the tokenize command, use filterExpand. Depending on what you have selected, you may have an array that looks like: myObject.vtx[1:10] myObject.vtx[32:58], etc. In that case, tokenize will work. But your selection can also return something like: myObect.vtx[5] myObject.vtx[32:61], etc.
So your script will return, for the first one:
myObject.vtx[5]]
And Maya will return an error.

Code:
string $vfList [] = `polyListComponentConversion -tv -fe`; if (size ($vfList))//checks if the selection is not empty { //this variable must be declared outside the condition //if you want to use it elsewhere string $allVertices [] = `filterExpand -sm 31 $vfList`;//transforms the concatenated list in a nice long list select -r $allVertices;//or do whatever you want... } else warning "nothing's selected!";

Last edited by depakeen : 02-08-2013 at 05:04 PM.
 
Old 02-08-2013, 07:14 PM   #8
Yosemany
New Member
portfolio
 
Join Date: Feb 2013
Posts: 15
Depakeen - I see what you mean on both counts. A significant improvement on my code.

Thanks all. Hope I can repay you by helping with your problems too, when I've gained a bit more experience.
 
Old 02-10-2013, 03:56 PM   #9
gmask
Obfuscator
 
gmask's Avatar
gmask
Power Sitting
Topanga, USA
 
Join Date: Oct 2002
Posts: 6,937
I believe this also works..

select myObject.vtx[*]
__________________
blah blah blah
 
Old 02-10-2013, 03:56 PM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:08 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.