Skip to content

Instantly share code, notes, and snippets.

@kohyuk91
Last active November 20, 2019 14:21
Show Gist options
  • Select an option

  • Save kohyuk91/7edce53bc0c5dfa7a38c775e2edbd51e to your computer and use it in GitHub Desktop.

Select an option

Save kohyuk91/7edce53bc0c5dfa7a38c775e2edbd51e to your computer and use it in GitHub Desktop.
global proc shelf_Matchmove () {
global string $gBuffStr;
global string $gBuffStr0;
global string $gBuffStr1;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "OSCAM"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "OSCAM"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "##\n## Script:\t\toverscan.py v1.0\n##\n## Author:\t\tHyuk Ko\n##\t\t\t\[email protected]\n##\n## Date:\t\t2017.01.30\n##\n## Description:\tComputes overscan value to the Filmback's Horizontal & Vertical values. \n##\n## Usage:\t\t1.Select Camera and press 'GET'\n## 2.Write Original Plate width & height values\n## 3.Press 'OVERSCAN'\n\nimport maya.cmds as mc\n\nclass Overscan():\n\n def __init__(self):\n ################################# UI\n self.win = 'OVERSCAN'\n #################################\n \n ################################# Strings\n self.camName = 'Select Camera'\n self.camShape = ''\n self.imgPlaneName = ''\n \n self.labelX = 'ORG IMAGE WIDTH'\n self.labelY = 'ORG IMAGE HEIGHT'\n \n self.orgCoverageX = 0\n self.orgCoverageY = 0\n self.newCoverageX = 0\n self.newCoverageY = 0\n \n self.overscanX = 0\n self.overscanY = 0\n \n self.orgHFA = 0\n self.orgVFA = 0\n \n self.orgSizeX = 0\n self.orgSizeY = 0\n #################################\n \n self.display()\n\n def display(self):\n\n if mc.window(self.win, exists=True):\n mc.deleteUI(self.win)\n \n mc.window(self.win, sizeable=True, resizeToFitChildren=True)\n \n mc.rowColumnLayout(nc=1)\n \n mc.separator(height=15, style='out') #############################\n \n mc.text(label='OVERSCAN', font='boldLabelFont')\n \n mc.separator(height=15, style='out') #############################\n \n mc.rowColumnLayout(nc=2, columnWidth=[(1,200),(2,50)]) \n mc.text('camName', label=self.camName)\n mc.button(label='Get', command=self.getCameraBTN)\n mc.setParent('..')\n \n mc.separator(height=15, style='out') #############################\n\n mc.rowColumnLayout(nc=2, columnWidth=[(1,125),(2,125)])\n mc.text('labelX', label=self.labelX)\n mc.text('labelY', label=self.labelY)\n mc.setParent('..') \n\n mc.rowColumnLayout(nc=2, columnWidth=[(1,125),(2,125)])\n mc.textField('orgCoverageX', text='')\n mc.textField('orgCoverageY', text='')\n mc.setParent('..')\n \n mc.separator(height=15, style='out') #############################\n \n mc.button(label='OVERSCAN', height=50, command=self.overscanBTN)\n \n mc.separator(height=15, style='out') #############################\n \n mc.showWindow(self.win)\n \n def getCameraBTN(self,a):\n if len(mc.ls(selection=True))==1 and mc.objectType(mc.listRelatives(mc.ls(selection=True), shapes=True)[0]) == 'camera':\n self.camName = mc.ls(selection=True)[0] # Get Camera\n self.camShape = mc.listRelatives(self.camName, shapes=True)[0] # Get 'Shape' of Camera\n self.imgPlaneName = mc.listConnections(self.camShape, type='imagePlane')[0] # Get 'imagePlane' of Camera\n \n self.orgHFA = mc.getAttr(self.camName + '.hfa') # Get Original Horizontal Film Aperture\n self.orgVFA = mc.getAttr(self.camName + '.vfa') # Get Original Vertical Film Aperture \n \n self.orgSizeX = mc.getAttr(self.imgPlaneName + '.sizeX') # Get Imageplane Original SizeX\n self.orgSizeY = mc.getAttr(self.imgPlaneName + '.sizeY') # Get Imageplane Original SizeY\n \n self.newCoverageX = mc.getAttr(self.imgPlaneName + '.coverageX')\n self.newCoverageY = mc.getAttr(self.imgPlaneName + '.coverageY')\n \n mc.text('camName', edit=True, label=self.camName)\n \n #print [self.camName, self.newCoverageX, self.newCoverageY]\n \n def overscanBTN(self,a):\n if self.camName != 'Select Camera' and mc.textField('orgCoverageX', q=True, text=True) != 0 and mc.textField('orgCoverageY', q=True, text=True) != 0:\n self.orgCoverageX = mc.textField('orgCoverageX', q=True, text=True) # Get Original Image Width\n self.orgCoverageY = mc.textField('orgCoverageY', q=True, text=True) # Get Original Image Height \n \n self.overscanX = self.newCoverageX / float(self.orgCoverageX)\n self.overscanY = self.newCoverageY / float(self.orgCoverageY)\n \n mc.setAttr(self.camName + '.hfa', self.orgHFA * self.overscanX)\n mc.setAttr(self.camName + '.vfa', self.orgVFA * self.overscanY)\n \n mc.setAttr(self.imgPlaneName + '.sizeX', self.orgSizeX * self.overscanX)\n mc.setAttr(self.imgPlaneName + '.sizeY', self.orgSizeY * self.overscanY)\n \n #print [self.orgCoverageX, self.orgCoverageY, self.overscanX, self.overscanY]\n \n \nif __name__ == '__main__':\n Overscan().display()"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
separator
-enable 1
-width 12
-height 35
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-style "shelf"
-horizontal 0
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "HO ON"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "HO ON"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "# Turn ON Hold-Out for All Objects in Scene\n# Usage: Just run script.\n\nimport maya.cmds as mc\n\ndef run():\n geometryList = mc.ls(geometry=True, long=True)\n \n for geo in geometryList:\n try:\n mc.setAttr(geo + '.holdOut', 1)\n except:\n pass\n \nrun()"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "HO OFF"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "HO OFF"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "# Turn OFF Hold-Out for All Objects in Scene\n# Usage: Just run script.\n\nimport maya.cmds as mc\n\ndef run():\n geometryList = mc.ls(geometry=True, long=True)\n \n for geo in geometryList:\n try:\n mc.setAttr(geo + '.holdOut', 0)\n except:\n pass\n \nrun()"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
separator
-enable 1
-width 12
-height 35
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-style "shelf"
-horizontal 0
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "PREV"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "PREV"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "# lookThruVisCam.py\n#\n# Author : HYUK KO / [email protected]\n\n'''\nimport lookThruVisCam\nlookThruVisCam.main(\"next\")\n'''\n\n'''\nimport lookThruVisCam\nlookThruVisCam.main(\"previous\")\n'''\n\nimport maya.cmds as mc\nimport maya.OpenMaya as om\nimport maya.OpenMayaUI as omui\n\ndef main(mode):\n selVisCamShapeList = mc.ls(cameras=True, visible=True, long=True)\n selVisCamShapeListSize = len(selVisCamShapeList)\n\n panelWithFocus = mc.getPanel(withFocus=True)\n\n activeView = omui.M3dView.active3dView()\n camDagPath = om.MDagPath()\n activeView.getCamera(camDagPath)\n currentCam = camDagPath.fullPathName()\n\n if selVisCamShapeListSize == 1:\n if currentCam == '|persp|perspShape':\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n mc.lookThru(panelWithFocus, '|persp|perspShape')\n elif mode == \"next\":\n if currentCam not in selVisCamShapeList:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n if selVisCamShapeList.index(currentCam) == selVisCamShapeListSize - 1:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) + 1])\n elif mode == \"previous\":\n if currentCam not in selVisCamShapeList:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n if selVisCamShapeList.index(currentCam) == 0:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeListSize - 1])\n else:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) - 1])\n \nmain(\"previous\")"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "NEXT"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "NEXT"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "# lookThruVisCam.py\n#\n# Author : HYUK KO / [email protected]\n\n'''\nimport lookThruVisCam\nlookThruVisCam.main(\"next\")\n'''\n\n'''\nimport lookThruVisCam\nlookThruVisCam.main(\"previous\")\n'''\n\nimport maya.cmds as mc\nimport maya.OpenMaya as om\nimport maya.OpenMayaUI as omui\n\ndef main(mode):\n selVisCamShapeList = mc.ls(cameras=True, visible=True, long=True)\n selVisCamShapeListSize = len(selVisCamShapeList)\n\n panelWithFocus = mc.getPanel(withFocus=True)\n\n activeView = omui.M3dView.active3dView()\n camDagPath = om.MDagPath()\n activeView.getCamera(camDagPath)\n currentCam = camDagPath.fullPathName()\n\n if selVisCamShapeListSize == 1:\n if currentCam == '|persp|perspShape':\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n mc.lookThru(panelWithFocus, '|persp|perspShape')\n elif mode == \"next\":\n if currentCam not in selVisCamShapeList:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n if selVisCamShapeList.index(currentCam) == selVisCamShapeListSize - 1:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) + 1])\n elif mode == \"previous\":\n if currentCam not in selVisCamShapeList:\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\n else:\n if selVisCamShapeList.index(currentCam) == 0:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeListSize - 1])\n else:\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) - 1])\n \nmain(\"next\")"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
separator
-enable 1
-width 12
-height 35
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-backgroundColor 0 0 0
-highlightColor 0.321569 0.521569 0.65098
-style "shelf"
-horizontal 0
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "CONE"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "CONE"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "import maya.cmds as mc\n\n\n\"\"\" �������� ����Ʈ \"\"\"\nloc_list = mc.ls(selection=True) # [u'locator1', u'locator2', u'locator3']\n\nfor loc in loc_list:\n \n \"\"\" �簢�� �ܻ��� \"\"\"\n polycone = mc.polyCone(subdivisionsAxis=4)[0]\n \n \"\"\" ���� 180�� ȸ�� \"\"\"\n mc.xform(polycone, worldSpace=True, rotation=[180,0,0])\n \n \"\"\" ���� translateY�� 1 �ø� \"\"\"\n mc.xform(polycone, worldSpace=True, translation=[0,1,0])\n \n \"\"\" ���� �Ǻ��� ���� �߾����� �ű��� \"\"\"\n mc.xform(polycone, worldSpace=True, pivots=[0,0,0])\n \n \"\"\" ���� ������ \"\"\"\n mc.makeIdentity(polycone, apply=True)\n \n ##############################################################################\n \n \"\"\" ���������� �������� �˾Ƴ��� \"\"\"\n loc_position = mc.xform(loc, q=True, worldSpace=True, translation=True)\n \n \"\"\" ���� �������Ϳ� �̵� ��Ű�� \"\"\"\n mc.xform(polycone, worldSpace=True, translation=loc_position)"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
separator
-enable 1
-width 12
-height 35
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-backgroundColor 0 0 0
-highlightColor 0.321569 0.521569 0.65098
-style "shelf"
-horizontal 0
;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 35
-height 34
-manage 1
-visible 1
-preventOverride 0
-enableBackground 0
-align "center"
-label "HOTKEY"
-labelOffset 0
-rotation 0
-flipX 0
-flipY 0
-useAlpha 1
-font "plainLabelFont"
-imageOverlayLabel "HOTKEY"
-overlayLabelColor 0.8 0.8 0.8
-overlayLabelBackColor 0 0 0 0.5
-image "pythonFamily.png"
-image1 "pythonFamily.png"
-style "iconOnly"
-marginWidth 1
-marginHeight 1
-command "import maya.cmds as mc\n\ntry:\n mc.runTimeCommand(\"lookThruNextVisCam\", category=\"Custom Scripts\", commandLanguage=\"python\", command=\"# lookThruVisCam.py\\n#\\n# Author : HYUK KO / [email protected]\\n\\n'''\\nimport lookThruVisCam\\nlookThruVisCam.main(\\\"next\\\")\\n'''\\n\\n'''\\nimport lookThruVisCam\\nlookThruVisCam.main(\\\"previous\\\")\\n'''\\n\\nimport maya.cmds as mc\\nimport maya.OpenMaya as om\\nimport maya.OpenMayaUI as omui\\n\\ndef main(mode):\\n selVisCamShapeList = mc.ls(cameras=True, visible=True, long=True)\\n selVisCamShapeListSize = len(selVisCamShapeList)\\n\\n panelWithFocus = mc.getPanel(withFocus=True)\\n\\n activeView = omui.M3dView.active3dView()\\n camDagPath = om.MDagPath()\\n activeView.getCamera(camDagPath)\\n currentCam = camDagPath.fullPathName()\\n\\n if selVisCamShapeListSize == 1:\\n if currentCam == '|persp|perspShape':\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n mc.lookThru(panelWithFocus, '|persp|perspShape')\\n elif mode == \\\"next\\\":\\n if currentCam not in selVisCamShapeList:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n if selVisCamShapeList.index(currentCam) == selVisCamShapeListSize - 1:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) + 1])\\n elif mode == \\\"previous\\\":\\n if currentCam not in selVisCamShapeList:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n if selVisCamShapeList.index(currentCam) == 0:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeListSize - 1])\\n else:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) - 1])\\n \\nmain(\\\"next\\\")\" )\n mc.nameCommand(\"lookThruNextVisCamNameCommand\", annotation=\"lookThruNextVisCamNameCommand\", sourceType=\"mel\", command=\"lookThruNextVisCam\")\nexcept:\n pass\n \ntry:\n mc.runTimeCommand(\"lookThruPrevVisCam\", category=\"Custom Scripts\", commandLanguage=\"python\", command=\"# lookThruVisCam.py\\n#\\n# Author : HYUK KO / [email protected]\\n\\n'''\\nimport lookThruVisCam\\nlookThruVisCam.main(\\\"next\\\")\\n'''\\n\\n'''\\nimport lookThruVisCam\\nlookThruVisCam.main(\\\"previous\\\")\\n'''\\n\\nimport maya.cmds as mc\\nimport maya.OpenMaya as om\\nimport maya.OpenMayaUI as omui\\n\\ndef main(mode):\\n selVisCamShapeList = mc.ls(cameras=True, visible=True, long=True)\\n selVisCamShapeListSize = len(selVisCamShapeList)\\n\\n panelWithFocus = mc.getPanel(withFocus=True)\\n\\n activeView = omui.M3dView.active3dView()\\n camDagPath = om.MDagPath()\\n activeView.getCamera(camDagPath)\\n currentCam = camDagPath.fullPathName()\\n\\n if selVisCamShapeListSize == 1:\\n if currentCam == '|persp|perspShape':\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n mc.lookThru(panelWithFocus, '|persp|perspShape')\\n elif mode == \\\"next\\\":\\n if currentCam not in selVisCamShapeList:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n if selVisCamShapeList.index(currentCam) == selVisCamShapeListSize - 1:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) + 1])\\n elif mode == \\\"previous\\\":\\n if currentCam not in selVisCamShapeList:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[0])\\n else:\\n if selVisCamShapeList.index(currentCam) == 0:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeListSize - 1])\\n else:\\n mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) - 1])\\n \\nmain(\\\"previous\\\")\" )\n mc.nameCommand(\"lookThruPrevVisCamNameCommand\", annotation=\"lookThruPrevVisCamNameCommand\", sourceType=\"mel\", command=\"lookThruPrevVisCam\")\nexcept:\n pass\n \nmc.confirmDialog(title=\"Confirm\", message=\"Check Custom Scripts in Hotkey Editor\")"
-sourceType "python"
-commandRepeatable 1
-flat 1
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment