[英]Why is exportSelected exporting non-selected nodes?
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.
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? 有必须从
exportSelected
删除的条件,还是必须添加的其他条件?
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
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.
这些标志会反映在pymel命令中,请尝试将其设置为false并在组合中播放一点,直到找到正确的标志为止。 http://download.autodesk.com/us/maya/2011help/PyMel/generated/functions/pymel.core.system/pymel.core.system.exportSelected.html
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. 此外,根据您正在谈论的资产的类型,如果仅仅是静态网格物体,装备或其他东西,问题也会变得更加棘手。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.