PDA

View Full Version : where in maya is the image format list found in render globals located?


DEVILSAN
12-09-2012, 01:27 PM
I want to access the list of image format used to render from maya render globals , I also want to access the renderers in the maya render globals (see attached image), can anyone tell me which mel file may have that or how I can access the whole list using python ?
http://area.autodesk.com/userdata/forum/s/screenshot_8-670x670.png

Nyro
12-09-2012, 03:05 PM
those imageformats are hardcoded into the renderGlobals node:

defaultRenderGlobals.imageFormat


That attribute is of type 'enum'. You can query it with 'getAttr -asString', but that will only return the enum value it is currently set to.

The command 'addAttr -q -en' allows you to list all the values associated with a particular enum-attribute, but it is limited to dynamic attributes, i.e. those the user adds himself, not those that are natively part of any node.

So you'll have to figure out a workaround, e.g. by creating a temporary object with a dynamic attribute (type enum), copying (using copyAttr) the enum values from the defaultRenderGlobals.imageFormat attribute to the new dynamic attribute, then using addAttr -query -en to get a list of attribute values.
THen you'll need to use some tokenizing and smart string manipulation (easier with python) to separate the actual value (integers) from the UI-String representation.

PozestStar
12-09-2012, 03:57 PM
EDIT: Whoops. Someone responded above me. Ignore me ^^


Someone may come along after me and tell you where to find the image format list, but I think you can just recreate it like this:


picExt = [] #File Extention
picExtNum = [] #File Extentions internal value (i.e. PSD is 31)
defaultImgFormat = getAttr ("defaultRenderGlobals.imageFormat") #The Default render setting so you can set it back later

picFormatMenu = mc.optionMenuGrp("pFormat", cw2 = (100, 150), label = "Image Format", ann = "The image format for the render will be:")

mc.menuItem(label = "ALS")
mc.menuItem(label = "CIN")
mc.menuItem(label = "EPS")
mc.menuItem(label = "GIF")
mc.menuItem(label = "JPEG"
mc.menuItem(label = "MAYA IFF")
mc.menuItem(label = "MAYA16 IFF")
mc.menuItem(label = "YUV")
mc.menuItem(label = "RLA")
mc.menuItem(label = "SGI")
mc.menuItem(label = "SGI16")
mc.menuItem(label = "PIC")
mc.menuItem(label = "PSD")
mc.menuItem(label = "TGA")
mc.menuItem(label = "TIFF")
mc.menuItem(label = "TIFF16")
mc.menuItem(label ="BMP")

picExt[1] = "als"
picExtNum[1] = 6

picExt[2] = "cin"
picExtNum[2] = 11

picExt[3] = "eps"
picExtNum[3] = 9

picExt[4] = "gif"
picExtNum[4] = 0

picExt[5] = "jpg"
picExtNum[5] = 8

picExt[6] = "iff"
picExtNum[6] = 7

picExt[7] = "iff"
picExtNum[7] = 10

picExt[8] = "yuv"
picExtNum[8] = 12

picExt[9] = "rla"
picExtNum[9] = 2

picExt[10] = "sgi"
picExtNum[10] = 5

picExt[11] = "sgi"
picExtNum[11] = 13

picExt[12] = "pic"
picExtNum[12] = 1

picExt[13] = "psd"
picExtNum[13] = 31

picExt[14] = "tga"
picExtNum[14] = 19

picExt[15] = "tif"
picExtNum[15] = 3

picExt[16] = "tif"
picExtNum[16] = 4

picExt[17] = "bmp"
picExtNum[17] = 20

#and then do
imgFormat = picExtNum[formatOption]


Then do a setAttr for the imgFormat somewhere else in your code.

DEVILSAN
12-10-2012, 05:23 AM
@Nyro @PozestStar (http://forums.cgsociety.org/member.php?u=280958): guys you gave your best effort, yesterday night i found these formats are located in /scripts/others/createImageFormats.mel file so I wrote a python script and parsed the values corresponding to the relevent index i.e. defaultRenderGlobals.imageFormat

phile = "E:/Program Files/Autodesk/Maya2013/scripts/others/createImageFormats.mel"
imageFormatIndex={}
try:
read_phile=open(phile,"r")
text =str(read_phile.read())

lst = text.split("$i =")
for each in lst:
if each.split()[0].split(";")[0].isdigit() :
if (each.split()[-1].split(";")[0].replace('"',"")).isalnum():
imageFormatIndex[each.split()[0].split(";")[0]]=each.split()[-1].split(";")[0].replace('"',"").upper()

finally:
read_phile.close()

imageFormatIndex.update({'12':'YUV'})
imageFormatIndex.update({'13':'SGI16'})
imageFormatIndex.update({'4':'TIF16'})
imageFormatIndex.update({'10':'MAYA16 IFF'})
imageFormatIndex.update({'7':'MAYA IFF'})
#See for yourself
for keys,values in imageFormatIndex.items():
print keys,values

gives me overwhelming feeling i am really getting good at python , however the above script is not the best way, I guess regex can give good result in few lines but I dont have much experience with regex..

CGTalk Moderation
12-10-2012, 05:23 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.