Issue with light bake in Maya

Hi guys,

Need a little help here. I’m trying to bake light info through scripting and I am having trouble with the ‘bakeAlpha’ attribute - I need to have it on.

This is a prototype code to reproduce the issue:


import pymel.core as pm
import maya.mel as mel

# create dummy cube
pm.polyCube()

# create bake set
x = "bakeSet"
if not pm.objExists(x):
    x = mel.eval('createBakeSet '+ x +' textureBakeSet;')

y = pm.PyNode(x)
y.setAttr('colorMode', 0)
y.setAttr('bakeAlpha', 1)
y.setAttr('alphaMode', 0)

# bake
pm.convertLightmapSetup(camera="persp", bo=y.name(), showcpv=True)

The error I get when I run this is: # Error: RuntimeError: Maya command error #

If I change the ‘bakeAlpha’ to 0, the script works - with no alpha though. Any idea?

Thanks!

I’ve finally found the solution for this issue. To get this working I had to add ‘ksg=True’ to the convertLightmapSetup function.

So, if you need the bakeAlpha to be on, the last line of the code above should be:

pm.convertLightmapSetup(camera=“persp”, bo=y.name(), showcpv=True, ksg=True)

Just sharing in case someone come across the same thing.