【问题标题】:Maya: Import the same FBX file multiple times using PythonMaya:使用 Python 多次导入同一个 FBX 文件
【发布时间】:2021-07-13 05:10:57
【问题描述】:

我在 Maya 中创建了一个按钮,按下该按钮可导入 .fbx 文件。当我再次按下按钮导入相同的 .fbx 时,它会覆盖场景中已经存在的那个,而目标是复制。

我想要实现的示例:我按下按钮并将“sphere.fbx”作为“sphere”导入到场景中。我再次按下按钮,它将“sphere.fbx”作为“sphere1”导入到场景中。

这就是我用来导入 .fbx 的全部内容:

cmds.file(shapePath + shapeList[value], i = True, mnc = True, ns = ":")

我已经尝试过寻找一些解决方案,但没有运气。

【问题讨论】:

  • 最好使用命名空间来处理导入,这由 cmds.file 命令中的 ns 参数控制。在那里尝试一些不同的字符串,我相信你会明白我的意思。这不是您正在寻找的确切解决方案,但我敢说这是正确的方法。

标签: python maya autodesk fbx


【解决方案1】:

事实证明,据我所知,您无法两次导入 fbx 文件。作为一种解决方法,您可以采取哪些措施:

  1. 尝试导入文件
  2. 如果不起作用,请导入 fbx 文件作为参考
  3. 将该参考部分作为场景。
# Attempt to import fbx into the scene
# returnNewNodes(rnn) flag will tell us if it added anything
new_nodes = cmds.file(file_path, i=True, rnn=True)
print("Nodes added: {}".format(new_nodes))

# If nothing was added to the scene, import as reference
if not new_nodes:
    cmds.file(file_path, mnc=True, reference=True)
    # Make reference part of the scene
    cmds.file(file_path, importReference=True)

【讨论】:

    猜你喜欢
    • 2018-03-08
    • 2017-12-17
    • 2018-03-13
    • 2017-03-20
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 2016-06-03
    • 2017-01-31
    相关资源
    最近更新 更多