new script

(kos) #1

tonight i made a dirty script for bringing the r,g,b values from 2d programs like psp etc. to blender with equivalent r-g-b values.because you all know that 2d programs use max 255 stages of r,g,b values where blender does if you want to bring the exact r,g,b values from an image tp blender you have to do some manual avoid that i made the script.i know…i know it’s very easy…but hey it contains buttons does it worthwhile to upload for you? :-?

(Pablosbrain) #2

Sounds great… I’m terrible when it comes to calculating things manually. Any help in exacting my 3D work is much appreciated!

(Schlops) #3

If you run Linux here is a usefull one-liner for you to get the rgb-values of a color you know the name of. Just put it in a file (I call it rgb), make it executable (chmod a+x rgb) and put it somewhere in your path. Example: rgb tan

showrgb | grep $1 | awk '{ printf("R: %.6f   G: %.6f   B: %.6f 	%s %s %s %s
",$1/255, $2/255, $3/255, $4, $5, $6, $7)}'

EDIT: Forgot to mention: you need showrgb installed (should come with your distribution)

(tHe-IcemAn) #4

Actually they use 256 stages of a color because you have to take ZERO into consideration ( 0 to 255 = 256 levels). Did you take that into account in your script?

(kos) #5

yeah zero too…i was in hurry.but any help on when select a mesh its corresponding materials are also selected in would have eased my task.

(theeth) #6

import Blender
MatList = []
ob = Blender.Object.GetSelected()
if ob:
        if and == "NMesh":
                MatList = [Blender.Material.Get(mat) for mat in]

that should work

or, if you’re a fan of beautifully compressed code, you can try:

import Blender
MatList = [[Blender.Material.Get(mat) for mat in for mat] for ob in Blender.Object.GetSelected() if and == "NMesh"]


(beatabix) #7

hot damn!
ever since i first saw blender’s 0.000 to 1.000 and everything in between colour system, i’ve though “how hard would it be to make a little script to convert these values to the 0-255 values that i recognise?”

lazy boy that i am, it’s taken me two years to not do it, and you’ve now saved me the trouble.