我试图记录我在Pyside2中为Maya编写的工具,当Sphinx尝试将脚本作为自动HTML生成模块导入时,出现错误。该工具本身可以正常运行,但是有关其编写方式的某些信息在Sphinx方面导致错误。我将在下面放一个示例代码和错误:
import maya.cmds as cmds
import maya.mel as mel
import os
import maya.OpenMayaUI as mui
from functools import partial
from PySide2 import QtWidgets,QtCore,QtGui
import shiboken2
import re
class LAYERS_WINDOW_TOOL(object):
def __init__(self):
self.light_types = ["volumeLight","areaLight","spotLight","pointLight","directionalLight","ambientLight","VRayLightRectShape"]
self.materials_VRayMtl = cmds.ls(type = "VRayMtl")
self.materials_phong = cmds.ls(type = "phong")
self.materials_blinn = cmds.ls(type = "blinn")
self.materials_lambert = cmds.ls(type = "lambert")
self.materials_surface_shader = cmds.ls(type = "surfaceShader")
self.materials_displacement = cmds.ls(type = "displacementShader")
self.displacement_nodes = cmds.ls(type = "VRayDisplacement")
self.placement_nodes = cmds.ls(type = "place2dTexture")
self.file_nodes = cmds.ls(type = "file")
self.gammaCorrect_nodes = cmds.ls(type = "gammaCorrect")
self.ramp_nodes = cmds.ls(type = "ramp")
self.layeredTexture = cmds.ls(type = "layeredTexture")
self.VRayBlendMtls = cmds.ls(type = "VRayBlendMtl")
self.VRayPlaceEnvTex_nodes = cmds.ls(type = "VRayPlaceEnvTex")
self.multiplyDivide = cmds.ls(type = "multiplyDivide")
self.remapHsv = cmds.ls(type = "remapHsv")
self.remapColor = cmds.ls(type = "remapColor")
self.materials = self.materials_VRayMtl + self.materials_phong + self.materials_blinn + self.materials_lambert + self.materials_surface_shader + self.placement_nodes + self.file_nodes + self.materials_displacement + self.displacement_nodes + self.layeredTexture + self.VRayBlendMtls + self.VRayPlaceEnvTex_nodes + self.ramp_nodes + self.gammaCorrect_nodes + self.multiplyDivide + self.remapHsv + self.remapColor
self.object_check_g = cmds.ls(g = True)
self.object_check_transform = cmds.ls(type = "transform")
self.object_check_cameras = cmds.ls(type = "camera")
self.object_check = self.object_check_g + self.object_check_transform + self.materials + self.object_check_cameras
self.lites = cmds.ls(lt = True)
self.vray_lights = []
for object in self.object_check:
node_type = cmds.nodeType(object)
for lite in self.light_types:
if node_type == lite:
self.vray_lights.append(object)
self.object_check.append("vraySettings")
我在终端窗口中遇到的错误是:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\sphinx\ext\autodoc\importer.py", line 154, in import_module
__import__(modname)
File "U:/cwinters/python_git_hub_pub\rebuild_layers.py", line 1425, in <module>
main()
File "U:/cwinters/python_git_hub_pub\rebuild_layers.py", line 1422, in main
layers_tool_inst = LAYERS_WINDOW_TOOL()
File "U:/cwinters/python_git_hub_pub\rebuild_layers.py", line 30, in __init__
self.materials = self.materials_VRayMtl + self.materials_phong + self.materials_blinn + self.materials_lambert + self.materials_surface_shader + self.placement_nodes + self.file_nodes + self.materials_displacement + self.displacement_nodes + self.layeredTexture + self.VRayBlendMtls + self.VRayPlaceEnvTex_nodes + self.ramp_nodes + self.gammaCorrect_nodes + self.multiplyDivide + self.remapHsv + self.remapColor
TypeError: unsupported operand type(s) for +: '_MockObject' and '_MockObject'
这行代码似乎正在破坏它,但是当在Maya中按预期方式运行该工具时,它运行良好。
self.materials = self.materials_VRayMtl + self.materials_phong + self.materials_blinn + self.materials_lambert + self.materials_surface_shader + self.placement_nodes + self.file_nodes + self.materials_displacement + self.displacement_nodes + self.layeredTexture + self.VRay + self.VRayPlaceEnvTex_nodes + self.ramp_nodes + self.gammaCorrect_nodes + self.multiplyDivide + self.remapHsv + self.remapColor