1

My goal is to export the root node, all children and everything required to recreate an asset (for example, materials), but not include anything extraneous (for example, a lighting rig used to demo the asset, but that is logically not part of the asset, and is not a child of the asset's root node either).

As a simple example, imagine the scene contains a sphere and a cube. Neither is a child of the other in the DAG. If I pass in the root node of the sphere, only the sphere should appear in the export. If I select the root node of the cube, only the cube should appear.

I thought my selection logic was incorrect, but I can see in the Script Editor that the correct nodes (and no others) are being selected.

But, no matter which root node I pass in, the whole scene (sphere and cube) are exported. Is there a condition I must remove from exportSelected, or another condition I must add?

import pymel.core as core

core.select(clear=True)
core.select(root, hierarchy=True)  # selects node hierarchy as expected
core.select(root, allDependencyNodes=True, add=True)  # selects textures
# (although it selects unrelated textures too)
core.system.exportSelected(target_path, shader=True, preserveReferences=True)
# but this exports the whole scene,
# including nodes that were not selected by the lines above
lofidevops
  • 15,528
  • 14
  • 79
  • 119
  • What for? What exactly do you mean by "everything required to recreate the scene", and why would you say that a lighting rig is not part of the scene? In general it's best to say what you want to do first, then describe your solution, then describe how the results differ. – Andreas Haferburg Feb 18 '16 at 14:07
  • @AndreasHaferburg I've completely overhauled the question, hope that helps :) – lofidevops Feb 18 '16 at 15:00

1 Answers1

0

This happens, because if stuff is connected somehow it will export that aswell, let say, you want to export a mesh, you select the mesh only but that mesh is an input to a deformer, you will most likely export the whole deformation stack. If you want to avoid that you need to disable some behaviors. If you check the export selected options you will see that has a field called: "Include these inputs". Those flags are reflected in the pymel command, try set those to false and play a little with the combination until you find the right one. http://download.autodesk.com/us/maya/2011help/PyMel/generated/functions/pymel.core.system/pymel.core.system.exportSelected.html

Also the question gets more tricky based on the kind of asset you are talking about, if is just static meshes, or a rig, or something else.

Marco Giordano
  • 600
  • 4
  • 14