MEL For Loop Problem

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  02 February 2018
MEL For Loop Problem

Hi,

I have this script where it creates a joint from a currently selected object. The script goes as follows

$Obj = `ls -sl`;


for ($item in $Obj)
{
$joint = `joint`;
parent -w;
select -cl;
select -r $Obj;
select -add $joint;
delete `pointConstraint`;
select -cl;
}


The code works for a single selection. But when I select several objects (which is the intent of this script), it returns an error of:
Error: Only one transform or joint can be selected for creation"

I checked on thisthread and it recommends clearing the object after the loop. I did that but it still returns an error.
The thread does present a solution but it has undeclared variable of which I am also unable to correct. And also hoping to find an answer on my version.

Thank you for your time.
 
  02 February 2018
Something like this maybe:


string $Obj[] = `ls -sl`;

for ($item in $Obj)
{
$joint = `joint`;
parent -w;
select -cl;
select $item;
select -add $joint;
delete `pointConstraint`;
select -cl;
}
__________________
ArtStation -- Facebook -- Gumroad (Maya scripts)
 
  02 February 2018
Originally Posted by klaudio2u: Something like this maybe:


string $Obj[] = `ls -sl`;

for ($item in $Obj)
{
$joint = `joint`;
parent -w;
select -cl;
select $item;
select -add $joint;
delete `pointConstraint`;
select -cl;
}
Thanks for the response mate but it still gives me the error:
Error: Only one transform or joint can be selected for creation
 
  02 February 2018
This then:


string $obj[] = `ls -sl`;
for ($item in $obj)
{
$joint = `joint $item`;
parent -w;
select -cl;
select -r $item;
select -add $joint;
delete `pointConstraint`;
select -cl;
}
__________________
ArtStation -- Facebook -- Gumroad (Maya scripts)
 
  02 February 2018
Thanks for the response Klaudio. It worked.
Never thought of adding the $item solves the problem.

But is there a way to remove the transform grp when creating the joints?
As I recall, the script does not call for that command (grouping) but Maya seems to insert it arbitrarily

You can see an illustration here
https://www.dropbox.com/s/bn69xdkm3...Script.jpg?dl=0

Sorry for the trouble.
 
  02 February 2018
Maybe using "ungroup" command instead of parent....

string $obj[] = `ls -sl`;
for ($item in $obj)
{
$joint = `joint $item`;
ungroup $item;
select -cl;
select -r $item;
select -add $joint;
delete `pointConstraint`;
select -cl;
}
__________________
ArtStation -- Facebook -- Gumroad (Maya scripts)
 
  02 February 2018
Thanks for the fix Klaudio. It now works.
I though the ungroup command and the parent -w works the same but it turns out it doesn't.
Thanks again!
 
reply share thread



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 09:04 AM.


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