# Is There A Command To Convert Hex-colors?

**URL:** https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601
**Category:** Maya
**Tags:** mel
**Created:** [September 26, 2005, 9:16am UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601 "2005-09-26T09:16:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [September 26, 2005, 9:16am UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601/1 "2005-09-26T09:16:37Z")

</div>

Hi there!

To get Colors from eg. Photoshop into Maya I always have to take the calculator and type in the R, G and B values seperately, divide them by 255 and put them in one by one. (when I want the color to be 0 to 1, I know I can turn the color chooser to 0 to 255) Or I pull my Maya window aside and pick a color from Photoshop, then put all windows where they belong again (Alt-Tab doesn't work with the color picker, it always returns white.) And picking works only from PS to Maya. The PS picker isn't that smart 😕

however. In PS there that Hex field. And it whould save a lot of time If I simply could use that number!

And BTW: Is there a way to edit the Maya Color Chooser? I can't find it in the Maya scripts. Don't tell me its programmed ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/mellow.gif)  
Between the 2 optionMenus RGB and 0to 255 in color chooser is still space for such a field.

---

<div class="post-metadata">

### Author: ![naughty](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@naughty](https://forum.highend3d.com/u/naughty)
#### Post date: [September 26, 2005, 12:11pm UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601/2 "2005-09-26T12:11:30Z")

</div>

I have this problem, and the only way I've come up with so far is to write a little proc for myself:

CODE  
global proc float[] convertRGB(float $rgb[])  
{  
&nbsp;&nbsp;&nbsp;&nbsp;float $result[3];  
&nbsp;&nbsp;&nbsp;&nbsp;for ($n=0; $n\<3; $n++)

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [September 26, 2005, 1:15pm UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601/3 "2005-09-26T13:15:51Z")

</div>

Hey Naughty!

So nothing Maya-Build in right? :[ hmm...  
Hope its not too complicated..

Yea editing the Color Chooser:  
You Know how it looks. What about putting a Hex-field right there:  
 ![](http://show.imagehosting.us/show/722959/0/nouser_722/T0_-1_722959.jpg)400) {this.resized=true; this.width=400; this.alt='Click here to open new window';}" onmouseover="if(this.resized) this.style.cursor='hand';" onclick="if(this.resized) {window.open('http://show.imagehosting.us/show/722959/0/nouser\_722/T0\_-1\_722959.jpg');}" /\>

Hum.. nice Idea. But first we need something to calculate the Number from Hex to 3 flaots and vice versa ;]

---

<div class="post-metadata">

### Author: ![naughty](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@naughty](https://forum.highend3d.com/u/naughty)
#### Post date: [September 26, 2005, 1:21pm UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601/4 "2005-09-26T13:21:41Z")

</div>

I got bored so I wrote this (in about 5 mins.. now I'm bored again.. ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/sad.gif) ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/wink.gif) )

CODE  
proc int getDecFromHex(string $char)  
{  
&nbsp;&nbsp;&nbsp;&nbsp;string $h = tolower($char);  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "a")&nbsp;&nbsp;&nbsp;&nbsp;return 10;  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "b")&nbsp;&nbsp;&nbsp;&nbsp;return 11;  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "c")&nbsp;&nbsp;&nbsp;&nbsp;return 12;  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "d")&nbsp;&nbsp;&nbsp;&nbsp;return 13;  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "e")&nbsp;&nbsp;&nbsp;&nbsp;return 14;  
&nbsp;&nbsp;&nbsp;&nbsp;if ($h == "f")&nbsp;&nbsp;&nbsp;&nbsp;return 15;  
&nbsp;&nbsp;&nbsp;&nbsp;return (int($h));  
}  
global proc int[] hexCalc(string $hex)  
{  
&nbsp;&nbsp;&nbsp;&nbsp;int $dec[];  
&nbsp;&nbsp;&nbsp;&nbsp;for ($f=1; $f\<size($hex); $f=$f+2)  
&nbsp;&nbsp;&nbsp;&nbsp;{

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [September 26, 2005, 3:48pm UTC](https://forum.highend3d.com/t/is-there-a-command-to-convert-hex-colors/3601/5 "2005-09-26T15:48:38Z")

</div>

Whooarrr! Hehe ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/laugh.gif) COOL!

It works! And thats ingenious in my eyes!!

Now I gotta new task for you:  
Find a way to edit the friggling Color Chooser. But I crawled the Maya scripts: No hit for "color chooser" (wich is the Title of the window) and neither "wheel" can be found (a frame is called so there) :[  
Where is that window build? I mean.. there are a lot of special controls inside. But it looks like MEL. Maybe they really programmed it. _shrug_

But thanks for the script! I gonna put it to my defaults ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/tongue.gif)
