Forum
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Selecting verts in mel from a constraint point group list 2 weeks 9 hours ago #874

  • k.rant91
  • k.rant91's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
Hello,

I'm trying to select the verts I placed in a constraints point group. 
select tailcoat_clothOutput2.vtx[2188:2190];
That works but as soon as I add the rest of the list, it does not. I tried adding commas but this did not help. 
select tailcoat_clothOutput2.vtx[2188:2190 2284 7493 7682 8423 8433 20699:20701];

I realize this is a very basic question, but I'm stuck. I just need to be able to select those verts in the list.
 

Please Log in or Create an account to join the conversation.

Selecting verts in mel from a constraint point group list 2 weeks 9 hours ago #875

  • Sebastian
  • Sebastian's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 135
  • Thank you received: 26
Hi  k.rant91 ,

The syntax for this would be:
select tailcoat_clothOutput2.vtx[1:5] tailcoat_clothOutput2.vtx[20] tailcoat_clothOutput2.vtx[30:90];

This could be a pain to format, so here is a quick mel script that should help you:
string $indices = "1:5 20 30:90";
string $node = "tailcoat_clothOutput2";
string $command = "select";
string $indicesSplit;
int $numTokens = tokenize($indices, " ", $indicesSplit);
for($token in $indicesSplit)
{
    $command += " " + $node + ".vtx[" + $token + "]";
}
$command += ";";
eval($command);
Just adapt the $indices and $node. The rest happens automatically.

I hope this helps.

Cheers,
Sebastian

Please Log in or Create an account to join the conversation.

Selecting verts in mel from a constraint point group list 2 weeks 8 hours ago #876

  • k.rant91
  • k.rant91's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
This looks helpful and I see what's it's trying to do but I am not that familiar with Mel and it's syntax. I'm getting that "$token" is an undeclared variable. 

Please Log in or Create an account to join the conversation.

Selecting verts in mel from a constraint point group list 2 weeks 8 hours ago #877

  • Sebastian
  • Sebastian's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 135
  • Thank you received: 26
Which Maya version are you using?
What specific script are you running, i.e. copy and paste it here please and I can check if anything got lost in translation :)

Also, you can obviously always manually edit the indices string to match the syntax required.

Cheers,
Sebastian 
 

Please Log in or Create an account to join the conversation.

Selecting verts in mel from a constraint point group list 2 weeks 7 hours ago #878

  • k.rant91
  • k.rant91's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
I am using Maya 2022.1

string $indices = "1383:1384 1394:1396 1399:1405 1415:1421 1431:1437 2508:2511 2549:2552 3291:3293 18398:18399 18406 18424:18425 18428:18430 18432 18436 18438:18452 18454:18455 18473 18475:18489 18491:18492 18510 18512:18526 18528:18529 21052:21055 21595:21597 21599 21626 21628 21630 22382:22384 24167 24179:24181 24185:24191 24202:24209 24219:24226 25360:25363 25701:25703 25716:25719 26197:26200 1386 18404 18405 24170 24171 18407 3290 18408 22381 1387 26196 18411 18410 24192 21603 25704 18431 24182 18426 21624";
string $node = "tailcoat_clothOutput2";
string $command = "select";
string $indicesSplit;
int $numTokens = tokenize($indices, " ", $indicesSplit);
for($token in $indicesSplit)
{
    $command += " " + $node + ".vtx[" + $token + "]";
}
$command += ";";
eval($command);
// Error: for($token in $indicesSplit)
 // 
// Error: Line 6.28: Expression in "for <id> in <expr>" statement must be an array type. // 
// Error:     $command += " " + $node + ".vtx[" + $token + "]";
 // 
// Error: Line 8.48: "$token" is an undeclared variable. // 

Please Log in or Create an account to join the conversation.

Selecting verts in mel from a constraint point group list 1 week 6 days ago #881

  • Sebastian
  • Sebastian's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 135
  • Thank you received: 26
Ah, I see, something must have gone wrong in the copy and past to my post.
I still have the original script in my script editor where it is correct but in my post, it's missing some brackets.
Just checked and the forum post text editor actively removed them when I toggle between source and normal editor view.
Looks to be a bug in the forum software.
I am very sorry about that.
Here is your script with all the correct brackets:
string $indices = "1383:1384 1394:1396 1399:1405 1415:1421 1431:1437 2508:2511 2549:2552 3291:3293 18398:18399 18406 18424:18425 18428:18430 18432 18436 18438:18452 18454:18455 18473 18475:18489 18491:18492 18510 18512:18526 18528:18529 21052:21055 21595:21597 21599 21626 21628 21630 22382:22384 24167 24179:24181 24185:24191 24202:24209 24219:24226 25360:25363 25701:25703 25716:25719 26197:26200 1386 18404 18405 24170 24171 18407 3290 18408 22381 1387 26196 18411 18410 24192 21603 25704 18431 24182 18426 21624";
string $node = "tailcoat_clothOutput2";
string $command = "select";
string $indicesSplit[];
int $numTokens = tokenize($indices, " ", $indicesSplit);
for($token in $indicesSplit)
{
$command += " " + $node + ".vtx[" + $token + "]";
}
$command += ";";
eval($command);

This should work now.

(and just in case, here is the unformatted version)

string $indices = "1383:1384 1394:1396 1399:1405 1415:1421 1431:1437 2508:2511 2549:2552 3291:3293 18398:18399 18406 18424:18425 18428:18430 18432 18436 18438:18452 18454:18455 18473 18475:18489 18491:18492 18510 18512:18526 18528:18529 21052:21055 21595:21597 21599 21626 21628 21630 22382:22384 24167 24179:24181 24185:24191 24202:24209 24219:24226 25360:25363 25701:25703 25716:25719 26197:26200 1386 18404 18405 24170 24171 18407 3290 18408 22381 1387 26196 18411 18410 24192 21603 25704 18431 24182 18426 21624";
string $node = "tailcoat_clothOutput2";
string $command = "select";
string $indicesSplit[];
int $numTokens = tokenize($indices, " ", $indicesSplit);
for($token in $indicesSplit)
{
    $command += " " + $node + ".vtx[" + $token + "]";
}
$command += ";";
eval($command);

Again, so sorry about the error. It removed the in the line saying 
string $indicesSplit[];
I hope everything is working now.

Cheers,
Sebastian

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.074 seconds