PDA

View Full Version : excuting a command stored in a string in MEL


D4ng3rmouse
07-04-2007, 10:06 AM
Hey im just having a little bit of problem with this bit of code i have written

string $bones[] = `ls -sl`;
string $bone;
int $size_of_array = size($bones);
vector $bone_wp[];
int $i = 0;
for ($bone in $bones)
{
$bone_wp[$i] = `xform -ws -q -t $bone`;
$i++;
}

$i = 0;
string $curve= "-d 2";
for ($bone in $bones)
{
$curve = $curve + " -p " + $bone_wp[$i];
$i++;
}

curve $curve;

the code is just storing a taking all the worlds space positions of a selection of bones. These values are then passed into a string one after another with the -p flag used for curves put in between so ill end up with something like

-d 2 -p 0 0 0 -p 1 1 1 -p 2 2 2

now i thought i could then just do

curve $curve as this would effectivly be curve -d 2 -p 0 0 0 -p 1 1 1 -p 2 2 2

unfortunatly though this doesn't seem to be working. Anybody got any ideas how i can used my stored value to create the curve i want. I'm sure there is a way to do it mayeb im just being a bit slow this morning and have missed something simple. Sorry if this question has been answered else where in the forum but i only had a quick glance and couldn't see anything
Ta James

D4ng3rmouse
07-04-2007, 10:42 AM
tis ok found my own answer just have to use the eval command

so save my whole command in $curve and then do
eval($curve)

CGTalk Moderation
07-04-2007, 10:42 AM
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.