Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 17-11-2003, 11:16 PM   #1
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default 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?
Dann is offline   Reply With Quote
Old 17-11-2003, 11:52 PM   #2
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 18-11-2003, 12:35 AM   #3
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Dann is offline   Reply With Quote
Old 18-11-2003, 08:55 AM   #4
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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

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!
kbrown is offline   Reply With Quote
Old 18-11-2003, 03:28 PM   #5
ragecgi
Super Moderator
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks: 0
Thanked 13 Times in 12 Posts
Default

Thanks K!!!
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
ragecgi is offline   Reply With Quote
Old 18-11-2003, 06:11 PM   #6
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Dann is offline   Reply With Quote
Old 18-11-2003, 06:43 PM   #7
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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!
kbrown is offline   Reply With Quote
Old 18-11-2003, 06:51 PM   #8
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

ohhhhhhhhhhhh...

You're my new hero. Thanks K!!!
Dann is offline   Reply With Quote
Old 18-11-2003, 07:22 PM   #9
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

No problem

Learned myself something too in the process
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 18-11-2003, 08:03 PM   #10
ragecgi
Super Moderator
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks: 0
Thanked 13 Times in 12 Posts
Default

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 industry

Happy, happy, joy, joy
__________________
Israel "Izzy" Long
Motion and Title Design for Broadcast-Film-DS
izzylong.com
ragecgi is offline   Reply With Quote
Old 18-11-2003, 08:09 PM   #11
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

I totally agree with you Rage

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

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
__________________
Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
kbrown is offline   Reply With Quote
Old 19-11-2003, 04:35 AM   #12
ragecgi
Super Moderator
 
ragecgi's Avatar
 
Join Date: Sep 2002
Location: Minnesota, USA
Posts: 3,709
Thanks: 0
Thanked 13 Times in 12 Posts
Default

LOL! no kidding

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
ragecgi is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.