Skip to content

Instantly share code, notes, and snippets.

@redglasses67
Last active February 20, 2025 11:57
Show Gist options
  • Save redglasses67/afd442efe7cde3435b5a3b1d07abcc57 to your computer and use it in GitHub Desktop.
Save redglasses67/afd442efe7cde3435b5a3b1d07abcc57 to your computer and use it in GitHub Desktop.
Maya_ModelPanel_Scripts
# -*- coding: utf-8 -*-
import maya.cmds as mc
import maya.mel as mel
# 33 のビュー変換で使用する名前の一覧クラス. 変更時に文字列指定するので事前にこのように用意しておくと楽そう
class ViewTransformName():
ACES_RRT_v_0_7 = "ACES RRT v0.7"
ACES_RRT_v_1_0 = "ACES RRT v1.0"
Log = "Log"
_1_8_gamma = "1.8 gamma"
_2_2_gamma = "2.2 gamma"
Rec_709_gamma = "Rec 709 gamma"
sRGB_gamma = "sRGB gamma"
Raw = "Raw"
Stingray_tone_map = "Stingray tone-map"
modelPanels = mc.getPanel(type="modelPanel")
for panel in modelPanels:
cam = mc.modelEditor(panel, q=True, camera=True)
camShape = mc.listRelatives(cam, shapes=True)[0]
# 1 カメラの選択 : Select camera
mel.eval("eval select `getCameraNode view {0}` `getCameraNode up {0}` {0};".format(cam))
# 2 カメラをロック : Lock Camera
mel.eval("changeCameraLockStatus {0};".format(panel))
# 3 カメラ アトリビュート : Camera attributes
mel.eval("showPanelCameraEditor {0};".format(panel))
# 4 ブックマーク : Bookmarks
mc.cameraView(camera=cam, addBookmark=True)
# 5 イメージプレーン : Image Plane
imagePlanes = mc.listConnections(camShape + ".imagePlane")
if imagePlanes is None:
mel.eval('string $camShape[] = `ls %s`;'%camShape)
mel.eval("importImagePlane $camShape;")
elif mc.getAttr("{0}.displayMode".format(imagePlanes[0])) == 0:
mc.setAttr("{0}.displayMode".format(imagePlanes[0]), 3)
else:
mc.setAttr("{0}.displayMode".format(imagePlanes[0]), 1)
# 6 2D パン/ズーム : 2D Pan/Zoom
mc.camera(cam, e=True, panZoomEnabled=True)
# 7 グリースペンシル : Grease Pencil
mel.eval("createGreasePencilWindow();")
# 8 グリッド : Grid
mc.modelEditor(panel, e=True, grid=True)
# 9 フィルムゲート : Film gate
mc.camera(cam, e=True, displayFilmGate=True, displayResolution=False, overscan=1.3)
# 10 解像度ゲート : Resolution gate
mc.camera(cam, e=True, displayResolution=True, displayFilmGate=False, overscan=1.3)
# 11 ゲートマスク : Gate mask
mc.camera(cam, e=True, displayGateMask=True)
# 12 フィールドチャート : Field chart
mc.camera(cam, e=True, displayFieldChart=True)
# 13 セーフアクション : Safe action
mc.camera(cam, e=True, displaySafeAction=True)
# 14 セーフタイトル : Safe title
mc.camera(cam, e=True, displaySafeTitle=True)
# 15 ワイヤーフレーム : Wireframe
mc.modelEditor(panel, e=True, displayAppearance="wireframe", displayLights="default")
# もしくは
mc.modelEditor(panel, e=True, wireframeOnShaded=True)
# 16 すべてをスムーズシェード : Smooth shade all
mc.modelEditor(panel, e=True, displayAppearance="smoothShaded", displayLights="default")
# 17 規定のマテリアルの使用 : Use default material
mc.modelEditor(panel, e=True, useDefaultMaterial=True)
# 18 ワイヤフレーム付きシェード : Wireframe on shaded
mc.modelEditor(panel, e=True, wireframeOnShaded=True)
# 19 テクスチャ : Textured
mc.modelEditor(panel, e=True, displayTextures=True)
# 20 すべてのライトを使用 : Use all lights
mc.modelEditor(panel, e=True, displayLights="all")
# 21 シャドウ : Shadows
mc.modelEditor(panel, e=True, shadows=True)
# 22 スクリーン スペース アンビエント オクルージョン : Screen space ambient occlusion
mc.setAttr("hardwareRenderingGlobals.ssaoEnable", True)
# 23 モーション ブラー : Motion blur
mc.setAttr("hardwareRenderingGlobals.motionBlurEnable", True)
# 24 マルチサンプル アンチエイリアシング : Multisample anti-aliasing
mc.setAttr("hardwareRenderingGlobals.multiSampleEnable", True)
# 25 被写界深度 : Depth Of Field
mc.modelEditor(panel, e=True, depthOfFieldPreview=True)
# 26 選択項目の分離 : Isolate select
mel.eval('enableIsolateSelect("{0}", 1);'.format(panel))
# 27 X 線 : XRay
mc.modelEditor(panel, e=True, xray=True)
# 28 X 線アクティブ コンポーネント : XRay active components
mc.modelEditor(panel, e=True, activeComponentsXray=True)
# 29 ジョイントの X 線表示 : XRay joints
mc.modelEditor(panel, e=True, jointXray=True)
# 30 露出値 : Exposure
c.modelEditor(panel, e=True, exposure=0.0)
# 31 ガンマ : Gamma
mc.modelEditor(panel, e=True, gamma=1.0)
# 32 カラー管理 : Color management
mc.modelEditor(panel, e=True, cmEnabled=True)
# 33 ビュー変換 : View Transform
mc.modelEditor(panel, e=True, viewTransformName=ViewTransformName.Raw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment