How to create V-Ray attribute via MEL or Python?

Hi,

I’d like to be able to add “Texture input gamma” to a file node, but I’d like to do it using either MEL or Python. What is the correct syntax to do this?

If I were to do it via the Maya UI, I’d select the file node and then click “Attributes → V-Ray → Texture input gamma”.

The way to find the command is:
0. Open the script editor
1. Enable History->Echo all commands in the script editor
2. Clear the log Edit->Clear history
3. Select the node and add the attributes you’re interested in
4. Search the history in the script editor for a line starting with "vray addAttributesFromGroup " (without the quote).
    If you find such line then this is the command you can use to create the attributes with a script.

Hope it helps.

Excellent, thank you very much for the swift response. I found the MEL command and it works great!

Use the help, most of the extra attribue scripting is there.

Dragging up a slightly old thread, I see the commands in the help docs, but whats the best way to use that command via python? Hopefully something better than using eval()

I just looked this up, all you need is here:

Oh that looks interesting thanks, I have used the eval so far, and then worked out how to set the attrbute (not a big deal but Im new to maya)


# Set material ID to index of the loop
VRayMaterial.vrayMaterialId.set(5)

Ideally I want this! But I don’t understand where the attribute comes from (I see the commands are attribute from group)

VRayMaterial.addAttribute('[COLOR=#333333][FONT=Arial]vray_material_id[/FONT][/COLOR]')

(using pymel)

I guess I there is no pymel equivilant of “cmds.vray” ?

Better than eval anyway thank you.

> I guess I there is no pymel equivilant of “cmds.vray” ?

Nope.

Thanks Fredrik :slight_smile: