获取当前相机

第一种:

1
2
3
4
5
import maya.cmds as mc
print(mc.lookThru(q=True))

print(type(mc.lookThru(q=True)))

第二种:

1
2
3
4
5
import pymel.core as pm 
print(pm.lookThru(q=True))

print(type(pm.lookThru(q=True)))

第三种:

1
2
3
4
5
6
7
8
9
10
11
12
import pymel.core as pm
import maya.OpenMaya as OpenMaya
import maya.OpenMayaUI as OpenMayaUI
view = OpenMayaUI.M3dView.active3dView()
cam_dag = OpenMaya.MDagPath()
view.getCamera(cam_dag)
camera_path_name = cam_dag.fullPathName()
camera_name = pm.listRelatives(camera_path_name, parent=True)[0]
print(camera_name)

print(type(camera_name))

三种方法虽然获取到的相机类型不一样,但是都能获取当前屏幕视角的相机名称


获取当前相机
https://tdxhb.com/2023/07/21/TD/Maya/编程/获取当前相机/
作者
一只龙
发布于
2023年7月21日
许可协议