1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

mayaがエラー・ワーニングを吐く時の対処 7 ~fileLoadMonitor~

Last updated at Posted at 2022-03-24

maya2020にて特定のファイルを open / impotするとこんなエラーがでる

// Error: TypeError: file C:\Program Files\Autodesk\Maya2020\Python\lib\site-packages\maya\app\renderSetup\model\fileLoadMonitor.py line 102: 'NoneType' object has no attribute '__getitem__' // 

pyなので、とりあえず中身を見てみましょうか。

def _getErrorSwitchToRenderLayerIfNeeded():
	# If we have a render layer manager with render layers (not connected to render setup layers)
	# in the scene, then return an error warning the user that the combination of render setup and 
	# legacy render layers is not supported.
	renderLayerManagers = cmds.ls(type="renderLayerManager")
	for renderLayerManager in renderLayerManagers:
		size = cmds.getAttr(renderLayerManager + ".renderLayerId", size=True)
		allRenderLayers = (cmds.listConnections(renderLayerManager + ".renderLayerId[" + str(i) + "]")[0] for i in range(0, size))
		numRenderLayers = len([rsl for rsl in (legacyRenderLayer.renderSetupLayer(rl) for rl in allRenderLayers) if rsl is None])

		# It's ok to import or reference a file that has a render layer manager and one
		# legacy render layer (the default one). If the number of legacy render layers that
		# aren't used for render setup is greater than one, we have an intentional use of
		# legacy render layers and we should flag it.
		if numRenderLayers > 1:
			return kErrorSwitchToRenderLayer
	return None

この中でエラーが起きてる様子。

おそらく

cmds.listConnections(renderLayerManager + ".renderLayerId[" + str(i) + "]")[0]

ここで、Noneが返ってきてエラーになってるんでしょうな。

ちょっと切り出して、エラー起きてるノードとattrを確認

renderLayerManagers = cmds.ls(type="renderLayerManager")
for renderLayerManager in renderLayerManagers:
    size = cmds.getAttr(renderLayerManager + ".renderLayerId", size=True)
    for i in range(0, size):
        
        try:
            cmds.listConnections(renderLayerManager + ".renderLayerId[" + str(i) + "]")[0]
        except:
            print renderLayerManager + ".renderLayerId[" + str(i) + "]"

importするとシーン内のrenderLayerManagerが残って、importするファイルに付属していた物は破棄されてしまうようなので反応せず。

openの場合はそのままなので、反応あり

renderLayerManager.renderLayerId[1]
renderLayerManager.renderLayerId[2]
renderLayerManager.renderLayerId[3]
renderLayerManager.renderLayerId[4]
renderLayerManager.renderLayerId[5]

image.png

なるほど、エラーになりますね。
簡単に対処する用のスクリプトを作成

renderLayerManagers = cmds.ls(type="renderLayerManager")
for renderLayerManager in renderLayerManagers:
    indexes = cmds.getAttr(renderLayerManager + ".renderLayerId", mi = True) or []
    for i in indexes:        
        try:
            cmds.listConnections(renderLayerManager + ".renderLayerId[" + str(i) + "]")[0]
        except:
            print renderLayerManager + ".renderLayerId[" + str(i) + "]"
            cmds.removeMultiInstance(renderLayerManager + ".renderLayerId[" + str(i) + "]")

cmds.getAttr(renderLayerManager + ".renderLayerId", size=True) だと正確なindexが取れないので
cmds.getAttr(renderLayerManager + ".renderLayerId", mi = True) に変更

そもそも何で空のindexが増えたのかは追加調査中。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?