-
Notifications
You must be signed in to change notification settings - Fork 0
/
dualImage.py
46 lines (32 loc) · 1.74 KB
/
dualImage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Author : HYUK KO | [email protected] | github.com/kohyuk91
import maya.cmds as mc
import maya.OpenMaya as om
import maya.OpenMayaUI as omui
def getActive3dViewCam():
active3dView = omui.M3dView.active3dView()
active3dViewCamDagPath = om.MDagPath()
active3dView.getCamera(active3dViewCamDagPath)
active3dViewCamShape = active3dViewCamDagPath.fullPathName()
active3dViewCamTrans = mc.listRelatives(active3dViewCamShape, parent=True, fullPath=True)[0]
return active3dViewCamShape, active3dViewCamTrans
def main():
if mc.objExists("*dualImagePlane*"):
mc.delete("*dualImagePlane*") # Delete existing "dualImagePlane"
return
active3dViewCamShape, active3dViewCamTrans = getActive3dViewCam()
try:
active3dViewCamImagePlaneShape = mc.listRelatives(active3dViewCamShape, allDescendents=True, type='imagePlane', fullPath=True)[0]
active3dViewCamImagePlaneShapeImageName = mc.getAttr(active3dViewCamImagePlaneShape+'.imageName')
except:
mc.warning("No image plane found in current view.")
return
dualImagePlaneTrans = mc.imagePlane(name="dualImagePlane", sia=False, fileName=active3dViewCamImagePlaneShapeImageName, camera=active3dViewCamTrans)[0]
dualImagePlaneShape = mc.listRelatives(dualImagePlaneTrans, shapes=True, fullPath=True)[0]
mc.setAttr(dualImagePlaneShape+'.useFrameExtension', 1)
mc.setAttr(dualImagePlaneShape+'.frameCache', mc.getAttr(active3dViewCamImagePlaneShape+'.frameCache'))
mc.setAttr(dualImagePlaneShape+'.alphaGain', 0.5)
# Depth Expression
mc.expression(s="{0}.depth = {1}.nearClipPlane + 1".format(dualImagePlaneShape, active3dViewCamShape), object=dualImagePlaneTrans)
mc.AttributeEditor()
if __name__ == "__main__":
main()