SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Lounges / Members Lounge / MEL headache!
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 03-12-2010, 10:02 AM   #1
happymat27
Subscriber
 
happymat27's Avatar
 
Join Date: Jul 2004
Posts: 1,257
Thanks: 0
Thanked 3 Times in 3 Posts
Default MEL headache!

Hi,

it's been an age since I've posted up here but I need a little help with MEL and I figured that this would be the place to ask.

So...

Imagine a curve with an unknown number of CV's, I have made a script to count the CV's and attach a cluster to each one. I now need to distribute the clusters along the X axis using 0.005 as a base and the sequence 1,2,4,8,16,32,64....etc as the multiplier.

So the first cluster would be at 0.005, the second at 0.010, the third at 0.020, the fourth at 0.040 and so on.

has anyone got an idea how I could achieve this with MEL?

Cheers,

Mat
__________________
Click here to visit my site
happymat27 is offline   Reply With Quote
Old 03-12-2010, 01:49 PM   #2
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

Hi Mat,

Hows things, not seen you about for ages?

You could use a if loop, create a variable that contains the start number, then set it for the end and what you need

$varible = whatever it is ;
if ($variable < final number)
{
Do something ;

$variable += increment number ;
}

with the above I think I may have mixed up between MEL and C# at some points! But the theory should work
__________________
"No pressure, no diamonds" Thomas Carlyle
gster123 is offline   Reply With Quote
Old 03-12-2010, 02:25 PM   #3
happymat27
Subscriber
 
happymat27's Avatar
 
Join Date: Jul 2004
Posts: 1,257
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey Steve,

yeah all is good thanks... working hard etc.
what about yourself, still at the Uni?

So yeah MEL, or any other programming language, has never been my forte but I've got this script.....

// counting the CV's in the curve
string $curve = "waveCurveShape";
int $numSpans = `getAttr ( $curve + ".spans" )`;
int $degree = `getAttr ( $curve + ".degree" )`;
int $numCVs = $numSpans + $degree;
// this just lets me know how many there are
print $numCVs;

// a cluster for each CV
for ($i=0; $i<=($numCVs - 1); $i++)
{
select -r waveCurve.cv[$i];
newCluster " -envelope 1";
}

// rename and group clusters
for ($i=1; $i<($numCVs +1); $i++)
{
rename ("cluster" +$i +("Handle")) ("waveCluster" +$i);
}

//group clusters to neaten the outliner
for ($i=1; $i<($numCVs +1); $i++)
{
select -add ("waveCluster" +$i);
}
group; xform -os -piv 0 0 0;
rename group1 clusterGroup;


Create any curve and call it waveCurve and then execute the script, it will count the CV's and then create a cluster for each CV.
I can move the clusters one at a time to wherever I want using the CV count ($numCVs) for instance.....

// sets the location in x to the number of cluster -1
for ($i=1; $i<($numCVs +1); $i++)
{
float $c = ($i-1); select -r ("waveCluster" + $i);
move -rpr ($c) 0 0;
}


So waveCluster1 will be at 0,0,0 then waveCluster2 wil be at 1,0,0 etc.

I need the X value to follow the number pattern...

0,1,2,4,8,16,32,64,128.... etc for however many verts/clusters there are in the curve but my MEL-ness is not anywhere near that standard!!

Got any ideas?

Hope you're well,

Mat
__________________
Click here to visit my site

Last edited by happymat27 : 03-12-2010 at 02:28 PM.
happymat27 is offline   Reply With Quote
Old 03-12-2010, 04:53 PM   #4
stwert
EduSciVis-er
 
Join Date: Dec 2005
Location: Toronto
Posts: 3,373
Thanks: 74
Thanked 710 Times in 642 Posts
Default

for ($i=0; $i<($numCVs); $i++){
float $c = ($i-1); select -r ("waveCluster" + 2^$i);
}

...like that?

Actually I'm not sure what the interior stuff should be, but the function would be 2^$i.
stwert is offline   Reply With Quote
Old 03-12-2010, 08:19 PM   #5
happymat27
Subscriber
 
happymat27's Avatar
 
Join Date: Jul 2004
Posts: 1,257
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Cheers for your thoughts,

I got it sorted.....

int $i;
float $x = 0.005;
for($i = 0; $i < $numberOfCVs; $i++)
{
$x *= 2;
// Do whatever needs to be done
}

Thanks to kbrown for that

Doubtless I'll be back again soon when I next get stuck!!

Cheers,

Mat
__________________
Click here to visit my site
happymat27 is offline   Reply With Quote
Old 05-12-2010, 08:43 AM   #6
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

Hi Mat,

Yeas still there, going ok really. How about yourself?

I'll mail you.

Cheers

Steve
__________________
"No pressure, no diamonds" Thomas Carlyle
gster123 is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 03:41 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.