Thank Justin. I don't have access to my code right now to check the differences between mine and this one but this code works perfectly fine. Thanks again.
________________________________ From: [email protected] <[email protected]> on behalf of Justin Israel <[email protected]> Sent: Sunday, August 19, 2018 9:37:26 PM To: [email protected] Subject: Re: [Maya-Python] Re: How to embed modelPanel to a pyqt ui (again) ? ** Incoming mail from outside The Mill ** On Sat, Aug 18, 2018 at 4:14 AM tim2018 <[email protected]<mailto:[email protected]>> wrote: Hello, Thanks for the examples but I noticed that none of the icons in modelEditorIconBar seem to work. Clicking on shaded or wireframe icons have no effect in the viewport. Does anyone know how to fix this problem? I am referring to example1. Thanks I've updated the original blog post with a Maya >= 2017 port of that example code: http://justinfx.com/2011/11/20/mixing-pyqt4-widgets-and-maya-ui-objects/ I tested it in Maya 2018 and it seems like the toolbar icons in the model editor worked just fine. Can you confirm? On Friday, 23 May 2014 13:50:56 UTC-4, oglop wrote: i know this <http:///> has been asked<https://groups.google.com/forum/#!topic/python_inside_maya/wioChE9IFDA> on 2011 and Justine has an awesome example here<https://gist.github.com/justinfx/1381489> you saw the last few lines i commented out the setObjectName xxxx and yyyyy, without them, when you run the code in maya, it successfully opens the ui, but when you press 4 or 5 on the modelPanel, you will see the following error message similar to : updateModelPanelBar MayaWindow|||formLayout1|viewPanes|modelPanel4|modelPanel5|modelPanel5; notice the ||| part. it seems as if without object names set, maya doesn't know how to find the newly created modelPanel. also if i'm using mainwindow i also see this error unless i set object names using an awkward workaround. example1 from PyQt4 import QtCore,QtGui import maya.cmds as cmds import maya.OpenMayaUI as OpenMayaUI import sip def getMayaWindow(): windowPointer = OpenMayaUI.MQtUtil.mainWindow() return sip.wrapinstance(long(windowPointer), QtCore.QObject) class MayaView(QtGui.QDialog): def __init__(self,parent=None,**kwargs): super(MayaView,self).__init__(parent,**kwargs) self.setObjectName('MyWindow') self.setWindowTitle('3dView') self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setContentsMargins(0,0,0,0) self.verticalLayout.setObjectName("mainLayout") applyBut = QtGui.QPushButton('Apply') closeBut = QtGui.QPushButton('Close') butLayout = QtGui.QHBoxLayout() butLayout.addWidget(applyBut) butLayout.addWidget(closeBut) butLayout.setObjectName("xxxBut") layout = OpenMayaUI.MQtUtil.fullName(long(sip.unwrapinstance(self.verticalLayout))) print "vertical layout",layout cmds.setParent(layout) paneLayoutName = cmds.paneLayout() # find a pointer to the paneLayout that we just created ptr = OpenMayaUI.MQtUtil.findControl(paneLayoutName) # warp the pointer into a python QObject self.paneLayout = sip.wrapinstance(long(ptr),QtCore.QObject) # new create a camera self.cameraName = cmds.camera(n='PickerView_camera')[0] cmds.hide(self.cameraName) cmds.viewFit(self.cameraName,all=True) self.modelPanelName = cmds.modelPanel(cam=self.cameraName,parent=paneLayoutName) # edit model panel modelEditorValue = cmds.modelPanel(self.modelPanelName,q=True,me=True) cmds.modelEditor(modelEditorValue,e=True,da='smoothShaded',ca=False,grid=False,hud=False,\ manipulators=False,displayTextures=True,ha=False,j=False,ikh=False,df=False,\ dim=False,lc=False,nc=True,wos=False,dl='default',av=False) # find a pointer to the modelPanel that we just created ptr = OpenMayaUI.MQtUtil.findControl(self.modelPanelName) #wrap the pointer into a python QObject self.modelPanel = sip.wrapinstance(long(ptr),QtCore.QObject) #add our QObject reference to the paneLayout to our layout self.verticalLayout.addWidget(self.paneLayout) self.verticalLayout.addLayout(butLayout) self.verticalLayout.setSpacing(0) self.setLayout(self.verticalLayout) self.setFixedSize(400,600) class MainWin(QtGui.QDialog): def __init__(self,parent=getMayaWindow()): super(MainWin,self).__init__(parent) cam = MayaView() # self.setObjectName('xxxxxx') but = QtGui.QPushButton('zzz') layout = QtGui.QVBoxLayout() layout.addWidget(but) layout.addWidget(cam) self.setLayout(layout) # layout.setObjectName('yyyyy') a = MainWin() a.show() example2: from PyQt4 import QtCore,QtGui import maya.cmds as cmds import maya.OpenMayaUI as OpenMayaUI import sip def getMayaWindow(): windowPointer = OpenMayaUI.MQtUtil.mainWindow() return sip.wrapinstance(long(windowPointer), QtCore.QObject) class MayaView(QtGui.QWidget): def __init__(self,parent=None,**kwargs): super(MayaView,self).__init__(parent,**kwargs) self.setObjectName('MyWindow') self.setWindowTitle('3dView') self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setContentsMargins(0,0,0,0) self.verticalLayout.setObjectName("mainLayout") applyBut = QtGui.QPushButton('Apply') closeBut = QtGui.QPushButton('Close') butLayout = QtGui.QHBoxLayout() butLayout.addWidget(applyBut) butLayout.addWidget(closeBut) layout = OpenMayaUI.MQtUtil.fullName(long(sip.unwrapinstance(self.verticalLayout))) cmds.setParent(layout) paneLayoutName = cmds.paneLayout() # find a pointer to the paneLayout that we just created ptr = OpenMayaUI.MQtUtil.findControl(paneLayoutName) # warp the pointer into a python QObject self.paneLayout = sip.wrapinstance(long(ptr),QtCore.QObject) # new create a camera self.cameraName = cmds.camera(n='PickerView_camera')[0] cmds.hide(self.cameraName) cmds.viewFit(self.cameraName,all=True) self.modelPanelName = cmds.modelPanel(cam=self.cameraName) cmds.panel(self.modelPanelName,e=True,mbv=False) flayout = cmds.modelPanel(self.modelPanelName,q=True,barLayout=True) cmds.frameLayout(flayout,e=True,collapse=True) # edit model panel modelEditorValue = cmds.modelPanel(self.modelPanelName,q=True,me=True) cmds.modelEditor(modelEditorValue,e=True,da='smoothShaded',ca=False,grid=False,hud=False,\ manipulators=False,displayTextures=True,ha=False,j=False,ikh=False,df=False,\ dim=False,lc=False,nc=True,wos=False,dl='default',av=False) # find a pointer to the modelPanel that we just created ptr = OpenMayaUI.MQtUtil.findControl(self.modelPanelName) #wrap the pointer into a python QObject self.modelPanel = sip.wrapinstance(long(ptr),QtCore.QObject) #add our QObject reference to the paneLayout to our layout self.verticalLayout.addWidget(self.paneLayout) self.verticalLayout.addLayout(butLayout) self.verticalLayout.setSpacing(0) self.setLayout(self.verticalLayout) self.setFixedSize(400,600) class MainWin(QtGui.QMainWindow): def __init__(self,parent=getMayaWindow()): super(MainWin,self).__init__(parent) self.setObjectName('QtMainWindow') self.mid = QtGui.QMdiArea() self.mid.setObjectName('QMdiArea') self.setCentralWidget(self.mid) cam = MayaView() self.mid.addSubWindow(cam) a = MainWin() a.show() -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/dfa30f8a-617b-4e4b-8aac-f373054739db%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/dfa30f8a-617b-4e4b-8aac-f373054739db%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA16iJOC3rq-OviFM2zX6TzwUUmQWz184f-VEHnoBwZ9PA%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA16iJOC3rq-OviFM2zX6TzwUUmQWz184f-VEHnoBwZ9PA%40mail.gmail.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/BL0PR02MB363517A5490B81A69CEC8B85D3320%40BL0PR02MB3635.namprd02.prod.outlook.com. For more options, visit https://groups.google.com/d/optout.
