Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Marmoset Toolbag: find material/object by name
import mset
# Smarter "findMaterial": doesn't print a message in the console
# or throw an error when the object to find doesn't exist.
def getMaterial(name, createIfNotFound=False):
found = None
objs = mset.getAllMaterials()
for obj in objs:
if obj.name == name:
found = obj
break;
if createIfNotFound and (found == None):
found = mset.Material(name=name)
return found
import mset
# Smarter "findObject" / "findInChildren": doesn't print a message in the console
# or throw an error when the object to find doesn't exist.
def getObject(name, parent=None):
found = None
if parent == None:
objs = mset.getAllObjects()
else:
objs = parent.getChildren()
for obj in objs:
if obj.name == name:
found = obj
break;
return found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.