ScriptSpot

Script

RAL to RGB Converter (+Hex)

By animnym · 2017-08-13

Date updated
2017-08-13
Downloads
Description

--RAL to RGB Converter--

Little tool for quick converting your RAL color to RGB and/or hexidecimal values.

--Installation--

Put the RALtoRGB folder in your .\scripts\Startup\ folder and restart 3dsmax.

In most cases this will be something like this:

C:\Program Files\Autodesk\3ds Max 20xx\scripts\Startup\

where 20xx is your 3ds max version.

Find the category named RALtoRGB in your Customize User Interface Dialog and then drag it on toolbar or assign a shortkey to it.

==Usage--

In the UI of the script fill in your 4 digit RAL code in the RAL field and click CONVERT.
Note that You have to fill in just the 4 numbers after RAL and nothing else or it will not work.
For example : If You want to find out the color of RAL1001 just fill in 1001 in the RAL field and click
CONVERT.

You can now copy the color RGB to any slot in max or use the hex value for external editors.

Enjoy

Pavel Parashkevov

Comments (2)

surfen281 · 2019-03-09

Hi Pavel - does RAL2RGB work in Max 2019?
I couldn't make it work here!?

Thanks!

In your script/startup

titane357 · 2019-03-11

Hi, thanks for your script !

@surfen281 In your script/startup folder, create a folder named "RALtoRGB" and put "ral_standard.csv" inside.

colors don't match ral classic : gamma problem for me
( enabled gamma lut 2.2 )
So I have modified one line, and a bit the UI :-) but colors are a bit off...

for exemple :
RAL 4001 your have 222,076,138 and on "https://www.couleursral.fr/ral-classic"
it is 129,97,131...



 (
--need ral_standard in RALtoRGB folder

rx = dotNetClass "System.Text.RegularExpressions.RegEx"
pattern = "(\d{4}),(\d{3})-(\d{3})-(\d{3})"
patternRalString = "(\d{4})"
patternRgbString = "(\d{3})-(\d{3})-(\d{3})"
FS_file_name =  ((GetDir #maxroot)+".//scripts//Startup//RALtoRGB//ral_standard.csv")

FS = openFile FS_file_name

fn ReadFile FS =
(
	local lineCount = 0
local stringLines = #()
local stringLinesRal = #()
	while not eof FS do ( 
	
	r = readline FS
	append  stringLines r
	lineCount = lineCount+1
	
	)

	seek FS 0
	close FS
	
	for s in stringLines do ( -- start append RAL string in array stringLinesRal
	if (((rx.match s pattern).success) == true) then 
		(
	RALstring =	((rx.match s pattern).tostring())
		
		append  stringLinesRal RALstring
					
			)

		)
	
	
	
	return stringLinesRal
	)
	
	strA = ReadFile FS
fn customRAL stringLinesRal RALstring_ = (

local color_

	for s in stringLinesRal do ( --start LinesRal loop

			if (((rx.match s patternRalString).tostring()) == RALstring_) then 
			(

			rgbString =  (((rx.match s patternRgbString).tostring()))
				rgbA = FilterString rgbString "-"
			
		color_ = color ((255*(((rgbA[1] as float)/255)^2.2)) as integer) ((255*(((rgbA[2] as float)/255)^2.2)) as integer) ((255*(((rgbA[3] as float)/255)^2.2)) as integer)
				
				return color_
				
			
			
			
			
			
			
			)  --end LinesRal loop
	)
	)--function ends
	
fn RGBtoHEX clrRGB = 
(
	
	R = bit.intAsHex clrRGB.r  
	if (R.count) < 2 then R = "0" +R
	G =  bit.intAsHex clrRGB.g
	if (G.count) < 2 then G = "0" +G
 	B =  bit.intAsHex clrRGB.b
	if (B.count) < 2 then B = "0" +B
	 
	
	return R+G+B


	
	
)
	
	
rollout RALtoRGB "RAL to RGB and Hex Converter" width:302 height:58
(
	edittext 'RALstringtxt' "RAL" pos:[5,5] width:80 height:20 align:#right
	edittext 'hex_text' "Hex" pos:[5,31] width:80 height:20 align:#left
	button 'goBtn' "CONVERT" pos:[90,4] width:60 height:50 align:#left
	colorPicker 'cp1' "" pos:[150,4] width:150 height:50 align:#left
	
	
	on goBtn pressed do
	(
	
	str1 = RALstringtxt.text
	col1 = customRAL strA str1
	cp1.color = col1
	hex_text.text = (RGBtoHex col1) as string
print col1
	)
)


	

	

createDialog RALtoRGB
)