def __init__(self, parent = None):
super(ModelEditor, self).__init__(parent)
self.modelEditorName = 'cstMEd'
self.paneLayoutName = 'ModEdPaneLayout'
self.modelEditorLayout = QGridLayout(self)
self.modelEditorLayout.setObjectName('%sQGridLayout' % self.modelEditorName)
self.editorPane = None
self.mymodelEditorPane = None
## delete existing editor
for each in cmds.lsUI(editors = True):
if self.modelEditorName in each:
cmds.deleteUI(each)
self.ptrVLayout = mui.MQtUtil.fullName(long(shiboken.getCppPointer(self.modelEditorLayout)[0]))
self.camera = 'persp'
## Define a maya pane for parenting to
self.editorPane = cmds.paneLayout(self.paneLayoutName)
self.wrapThisModelEditorPane = mui.MQtUtil.findLayout(self.editorPane)
## Wrap the pane for pyqt for parenting to
self.mymodelEditorPane = shiboken.wrapInstance(long(self.wrapThisModelEditorPane), QWidget)
self.mymodelEditorPane.setObjectName(self.paneLayoutName)
if cmds.modelEditor(self.modelEditorName, query = True, exists = True):
self.modelEditor = cmds.modelEditor(self.modelEditorName, edit = True, p = self.editorPane, activeView = True, nud = True, camera = self.camera)
else:
self.modelEditor = cmds.modelEditor(self.modelEditorName, p = self.editorPane, activeView = True, nud = True, camera = self.camera)
if cmds.modelEditor(self.modelEditorName, query = True, exists = True):
self.modelEditor = cmds.modelEditor(self.modelEditorName, edit = True, activeView = True, nud = True, camera = self.camera, p = self.editorPane)
else:
try:
self.modelEditor = cmds.modelEditor(self.modelEditorName, activeView = True, nud = True, camera = self.camera, p = self.editorPane)
except RuntimeError:
cmds.warning('Model Editor failed... Object base_OpenGL_Renderer not found.')
pass
# ## Add the menu at the top
self.menu = Menu(editor = self.modelEditorName)
self.modelEditorLayout.addWidget(self.menu, 0, 0)
self.modelEditorLayout.addWidget(self.mymodelEditorPane, 1, 0)
self.modelEditorLayout.setRowStretch(1, 1)
cmds.modelEditor(self.modelEditorName, edit = True, activeView = True)
self.modelEditorLayout.setContentsMargins(0,0,0,0)
self.setContentsMargins(0,0,0,0)
try:self.parent().closed.connect(self.close)
except AttributeError:pass
评论列表
文章目录