Hi guys,
I'm baking a lot of stuff in marmoset using python api, however today I've found that when I set baker.multipleTextureSets = True Marmoset found 0 texture sets in my model: baker.getTextureSetCount() retrns 0. Model is ok and have materials properly set: if I select baker in scene tree view by hand it refreshes its data and now it is ready to bake.
That's pretty annoying because I bake tens of similar objects in a batch, so I don't want to do it by hand each time.
How can I make marmoset to select my baker in list? I can't access its GUI, only to created by script.
Or maybe there is a way to make my baker update texture set list in python?
Thanks!
Just in case here's my code. Of course forum will kill all the identation but you'll got the idea. I set environment vars before launch it.
----------------------------------------------
import mset
import sys
import os
baker = None
tgt = os.getenv('MyMarmVarTgt')
lopath = os.getenv('MyMarmVarLo')
hipath = os.getenv('MyMarmVarHi')
res = os.getenv('MyMarmVarRes')
onlyVertexColor = os.getenv('MyMarmVarVc')
template_scene = os.getenv('MyMarmVarTemplate')
print(tgt)
print(lopath)
print(hipath)
print(template_scene)
mset.loadScene(template_scene)
try:
objlo = mset.importModel(lopath)
objhi = mset.importModel(hipath)
except Exception:
mset.quit()
# Find a baker:
for obj in mset.getAllObjects():
if isinstance(obj, mset.BakerObject):
baker = obj
try:
if baker != None:
# Setting up the baker
baker.outputPath = tgt
baker.outputBits = 8
baker.outputSamples = 16
baker.edgePadding = "Custom"
baker.edgePaddingSize = 16
baker.outputSoften = 0
baker.useHiddenMeshes = True
baker.ignoreTransforms = False
baker.smoothCage = True
baker.ignoreBackfaces = True
baker.multipleTextureSets = True
# These settings only apply if texture sets aren't enabled:
res_int = 4096
if res != '':
res_int = int(res)
baker.outputWidth = res_int
baker.outputHeight = res_int
for i in range(0, baker.getTextureSetCount() - 1):
baker.setTextureSetEnabled(i, True)
baker.setTextureSetWidth(i, res_int)
baker.setTextureSetHeight(i, res_int)
#print(type(objlo).__name__+"\n")
vc_enable = False
if onlyVertexColor == "true":
vc_enable = True
normalMap = baker.getMap("Normals")
normalMap.suffix = 'normal_base' #'normal-from-mesh'
normalMap.enabled = True
normalMap = baker.getMap("Vertex Color")
normalMap.suffix = 'id' # 'color-from-mesh'
normalMap.enabled = True
normalMap = baker.getMap("Curvature")
normalMap.suffix = 'curvature'
normalMap.enabled = not vc_enable
normalMap = baker.getMap("Normals (Object)")
normalMap.suffix = 'world_space_normals' # 'normal-world-space'
normalMap.enabled = not vc_enable
normalMap = baker.getMap("Position")
normalMap.suffix = 'position' #'position-from-mesh'
normalMap.enabled = not vc_enable
normalMap = baker.getMap("Ambient Occlusion")
normalMap.suffix = 'ambient_occlusion' #'ambient-occlusion-from-mesh'
normalMap.enabled = not vc_enable
#baker.savePreset("My Python Preset")
bg = baker.findInChildren('Bake Group')
bglo = bg.findInChildren('Low')
bghi = bg.findInChildren('High')
objlo.parent = bglo
objhi.parent = bghi
print("baking...\n")
mset.bakeAll(0)
#try:
# baker.bake()
# print(Exception)
# mset.quit()
else:
print("Could not find baker!")
except Exception:
mset.quit()
Replies
Is there any chance this bug fix can happen to Marmoset 3? I am encountering the same issue, and would very much like this functionality.
No, Toolbag 4 bug fixes will not be coming to older versions. You'll want to use the latest version for the most current features and bug fixes.
@EarthQuake Do you by any means know whether or not that has already been fixed? I am still encountering the same issue in Version 4043.
Or does anyone know if there is any smart workaround...?
Can confirm that I'm still having this issue in Version 4.043
I was actually able to get around this by just waiting a few seconds. Can't believe I didn't try this earlier.
Sadly doesn't fix it for me :(
Unfortunately I was too quick to respond and forget to remove my comment. My 'fix' doesn't solve the problem, I'm not sure why it worked for a few times before I posted that comment. Sorry for the false hope. Still looking for a solution.