I’ve pushed what is from my perspective an ideal method of collecting an asset from a Maya scene here.
It boils down to this.
# Capture nodes relevant to the model
nodes = cmds.file(exportSelected=True,
# Reduce to relevant nodes
shapes = cmds.ls(nodes,
Which does a few important things.
- It gathers all connected nodes, by relying on Maya’s export mechanism
- It then filters it down to data only relevant to validation and export.
From here, data is solely filtered downwards and no new data is added related to this instance.
The benefit is that (1) validation only ever touches data that is actually relevant and (2) a scene can be infinitely messy, but still come out ok. No validation happens on data that isn’t collected, and only relevant data is guaranteed to be collected.
This is in contrast to collecting via
cmds.ls(type="mesh") or similar, which assumes an entire scene is of interest, even though only part of it is ever exported, in this case an assembly by the name of
Extraction at this point may look like this.
constructionHistory=False is the key here. It will extract only what has been collected during collection, which is exactly what we are guaranteed to have validated.