python - 如何使用 Python 在 Maya 2017 中将选定对象添加到 renderLayerSetup?
问题描述
我正在尝试编写 Python 代码以仅在 Maya 中渲染选定对象,并想知道如何在 Maya 2017 中将选定对象添加到 renderLayerSetup ?
我尝试使用我找到的一些代码
import maya.app.renderSetup.model.renderSetup as renderSetup
rs = renderSetup.instance()
test = rs.createRenderLayer('render')
scene_Assets = test.createCollection('scene_Assets')
scene_Assets.getSelector().setPattern('name')
但是这段代码要求我使用对象名称添加到集合中
我希望输出能够将对象添加到集合中,而无需重命名所有名称。
解决方案
有点旧线程,只是偶然发现它,因为我正在谷歌搜索解决我自己的小头痛的方法,并认为我可能会有所帮助。(如果有人对如何获取集合中的集合对象有任何提示,请给我留言。我可以找到的模式,但不是通过添加或拖放添加的模式。)
无论如何,我实际上对编程有点陌生,所以这可能不是最佳解决方案,但它适用于 Maya 2018.6(上述答案对我不起作用),所以它可能对某人有所帮助:
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.cmds as mc
rs = renderSetup.instance()
#taking the selection and bring it through a for loop to format it.
selectionLi = mc.ls(sl=1)
selection=""
for each in selectionLi:
selection += each +", "
test = rs.createRenderLayer('render')
scene_Assets = test.createCollection('scene_Assets')
scene_Assets.getSelector().setPattern(str(selection))
推荐阅读
- facebook - Instagram API - 拉入单个用户提要的最简单方法
- python - 如何根据文件中的特定列对 IPv6 地址进行排序?
- sql - 为什么 count(case date) 也计算空情况?
- python - 网络爬虫可以区分编码吗?
- php - 无法将数据插入数据库laravel ajax
- python - zmq.Context() 在启动后挂起几分钟
- sql - Oracle 11g 中如何将动态列转换为行?
- sql - 如何在我的 ms 访问代码中修复此编译错误?
- java - 相同的appium代码不适用于相同的应用程序
- google-cloud-platform - 是否可以仅与另一个 Google 云帐户中的另一个用户共享存储桶