Introduction to Maya - Modeling Fundamentals Vol 2
This course will look in the fundamentals of modeling in Maya with an emphasis on creating good topology. It's aimed at people that have some modeling experience in Maya but are having trouble with complex objects.
# 1 17-11-2003 , 11:16 PM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695

Fireworks

I'm messing with Maya's fireworks. I want to use a MEL script to control the colors as described in the docs, but cannot figure it out.

Remake Color Palette

If you want to replace the entire sparks color palette with a custom palette, you can specify a custom MEL procedure name. Maya looks for the custom procedure by searching your user scripts directory for a MEL script with the same name.

Your procedure should include the following syntax:

global proc vector[] myFireworksColors( int $numColors )

In this syntax, the argument $numColors specifies the total number of colors requested. The return value should be an array of vectors with the new colors in it.
If you made individual color changes, you can return to the custom or default color palette by clicking Reset from colorProcedureName.

So I made a MEL script that says
global proc vector[] myFireworksColors( int $numColors );

I get an error though
// Error: global proc vector[] myFireworksColors( int $numColors );arksColor[1], $sparksColor[2]>>; //
// Error: Syntax error //

Any thoughts on what I should be doing?

# 2 17-11-2003 , 11:52 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
You have to do something like this:

Code:
global proc vector[] myFireworksColors( int $numColors )
{
	int $i;
	vector $vMyColorArray[];
	float $r, $g, $b;
	
	for($i = 0; $i < $numColors; $i++)
	{
		$r = rand(0, 1);
		$g = rand(0, 1);
		$b = rand(0, 1);
		
		$vMyColorArray[$i] = << $r, $g, $b >>;
	}
	
	return $vMyColorArray;
}
Hope I didn't make too many typos since I didn't tested it user added image


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 3 18-11-2003 , 12:35 AM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Hey kBrown,

Thanks for the assist, but a wierd thing is happening. When I created a script with that text called myworks02.mel, I get an error message
// Error: Cannot find procedure "myworks02". //

If I remove that text and go back to the simple command I had before that did nothing, it finds the script but of course doesn't work. I'm guessing it's a bogus error message meaning something else is wrong.

As I try to dissect and understand your MEL, might there be an error in the "for" condition? Doesn't it set $i to 0 every time? should it for $i ==0?

Also, $i is defined as an integer, but with no value. Does that automatically make it's value 0?

Thanks again,
-dann

# 4 18-11-2003 , 08:55 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198

Originally posted by Dann
Hey kBrown,

Thanks for the assist, but a wierd thing is happening. When I created a script with that text called myworks02.mel, I get an error message
// Error: Cannot find procedure "myworks02". //

Lemme guess. You didn't source your script? Just say "source myworks02.mel" in the command line. Or restart Maya. Otherwise Maya doesn't know a thing about your script.

One way would have been to copy-paste the script in to the script editor and execute it. This way the global procedure would have persisted in the memory until you quit Maya...

Originally posted by Dann
If I remove that text and go back to the simple command I had before that did nothing, it finds the script but of course doesn't work. I'm guessing it's a bogus error message meaning something else is wrong.

Not sure what you mean here...

Originally posted by Dann
As I try to dissect and understand your MEL, might there be an error in the "for" condition? Doesn't it set $i to 0 every time? should it for $i ==0?

Also, $i is defined as an integer, but with no value. Does that automatically make it's value 0?

Thanks again,
-dann

No, the script is a working one. I tested it after posting it user added image

The $i is defined as an integer and because I didn't assign it a value maya initializes it to 0.

The for loop is alright too. Please excuse my bad explanation but it's like:
Code:
// for( <iterator and initial value>, <test condition>, <what to do on every round )
   for(          $i = 0             , $i < $numColors ,  $i++                      )
Basically $i is first set to 0 and on every round it is incremented by 1 ($i++). The loop is repeated as long as the test condition is true ($i < $numColors).


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 5 18-11-2003 , 03:28 PM
ragecgi's Avatar
Registered User
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks K!!!


Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
# 6 18-11-2003 , 06:11 PM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
K,

First, let me say thank you for your help and patience with me. However I still cannot get this to work.

Originally posted by kbrown
Just say "source myworks02.mel" in the command line. Or restart Maya. Otherwise Maya doesn't know a thing about your script.

One way would have been to copy-paste the script in to the script editor and execute it. This way the global procedure would have persisted in the memory until you quit Maya...

When I type "source myworks02.mel" in the command line, not much happens (I suppose it's just loading into memory so not much would happen.) But then when I try and and put "myworks02" or "myworks02.mel" in the Fireworks creation box, I still get the same error. "Cannot find procedure". I even tried putting "source myworks02.mel" in the Firworks creation, but that didn't work either.

Any thoughts on what else I could be doing wrong? I'm still in Maya 4. Could that be the problem? Attached is my mel file. Maybe I did something wrong there, but it's just your code pasted in I think.

Thanks again.
-dann

# 7 18-11-2003 , 06:43 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
You're right about the sourcing. It just loads the script in to memory (and checks it for errors).

In the fireworks thing you need to point it to your procedure, not the mel file (the file could contain a number of other procedures). So in this case you should enter "myFireworksColors".


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 8 18-11-2003 , 06:51 PM
Dann's Avatar
Registered User
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
ohhhhhhhhhhhh...

You're my new hero. Thanks K!!!

# 9 18-11-2003 , 07:22 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
No problem user added image

Learned myself something too in the process user added image


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 10 18-11-2003 , 08:03 PM
ragecgi's Avatar
Registered User
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
I love it when you're messin with mel, and in my situation, dynamics in general, and youve been bangin your head against a wall for hours/days/weeks, when all of a sudden, CLICK!

...the lightbulb turns on, and a flood of excitement rushes over you as you are either:

-glad the hard-part of the project is over

or

-jumping to that next level of knowledge about our wonderfull industryuser added image

Happy, happy, joy, joyuser added image


Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
# 11 18-11-2003 , 08:09 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
I totally agree with you Rage user added image

After the CLICK you feel the adrenaline flowing and you could almost rule the world. You think to yourself "damn, i'm good!" user added image

The next second you start looking around if someone noticed the wide grin on you face and you realize that they propably think you're nuts user added image


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 12 19-11-2003 , 04:35 AM
ragecgi's Avatar
Registered User
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
LOL! no kiddinguser added image

When that stuff happens to me, I jump up and shout:

"I am the smartest man alive!"

.. it's usualy then that my gf laughs at me, and tells me that I still suck... hehe..


Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads