如何在 override.AbsOverride Maya 2018 或 2019 中设置属性 ('primaryVisibility')

how set set attribute ('primaryVisibility') in override.AbsOverride maya 2018 or 2019

如何在 override.AbsOverride maya 2018 或 2019

中设置属性 ('primaryVisibility')
import maya.app.renderSetup.model.override as override
import maya.app.renderSetup.model.selector as selector
import maya.app.renderSetup.model.collection as collection
import maya.app.renderSetup.model.renderLayer as renderLayer
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.cmds as cmds

rs = renderSetup.instance()    
# Create render layer

r1 = rs.createRenderLayer("char_beauty")


# Create collections

c1 = r1.createCollection("char")

c2 = r1.createCollection("trk_geo")

c2pv=c2.createCollection("PV")

c2pv.getSelector().setFilterType(2)


so=c2.createOverride('PV', override.AbsOverride.kTypeId)

so.setattribute('primaryVisibility')

尝试为 trk_geo 集合创建 primaryVisibility 属性..不知道在 AbsOverride 中设置 primaryVisibility 属性。

您的代码似乎缺少对覆盖的 finalize 方法调用:

import maya.app.renderSetup.model.override as override
import maya.app.renderSetup.model.selector as selector
import maya.app.renderSetup.model.collection as collection
import maya.app.renderSetup.model.renderLayer as renderLayer
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.cmds as cmds

rs = renderSetup.instance()    

# Create render layer
r1 = rs.createRenderLayer("char_beauty")

# Create collections
c1 = r1.createCollection("char")
c2 = r1.createCollection("trk_geo")
c2pv=c2.createCollection("PV")
c2pv.getSelector().setFilterType(2)

# Create override
so = c2.createOverride('PV', override.AbsOverride.kTypeId)
so.finalize('visibility')

如果您不知道属性的名称,您可以跳过最后一个 finalize 调用,然后通过从属性编辑器中拖放属性手动分配覆盖,然后调用print so.attributeName()查看真实姓名。