- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I have no real knowledge of Python but I usually get by scrounging bits and pieces off of scripts I find online, bits and pieces that are echoed in the Script Editor, etc. However, now I'm trying to continue writing something and I am stuck. I need some help! Please be gentle with me because again, and it may be obvious; I have no idea what I'm doing 😛
The situation is as follows: I have multiple scenes that already have a custom camera in them, but it has a different name in each scene, so I want to find whatever is not one of Maya's standard cameras, and make adjustments to it. So far I've been able to do everything I want to do except lock that camera's transforms. Because I start out with the Shape node and change attributes there, after that I want to get to the transform node and lock the translation and rotation.
Here's what I have, currently:
import maya.cmds as mc
mc.setAttr("defaultResolution.width", 1280)
mc.setAttr("defaultResolution.height", 720)
mc.setAttr ("hardwareRenderingGlobals.multiSampleEnable", 1)
for each_cam_shp in mc.ls(type="camera"):
exclude_cams=["frontShape","perspShape","sideShape","topShape"]
if each_cam_shp not in exclude_cams:
mc.setAttr(each_cam_shp+".displayFilmGate", True)
mc.setAttr(each_cam_shp+".filmFit", 3)
mc.setAttr(each_cam_shp+".overscan", 1)
mc.setAttr(each_cam_shp+".displayGateMaskOpacity", 0.99)
mc.setAttr(each_cam_shp+".displayGateMaskColor", 0,0,0, type='double3')
#here's where I need some help
each_cam_tr = mc.listRelatives(each_cam_shp, type='transform', parent=True, fullPath=True)
for each_cam_tr in each_cam_shp:
exclude_mayacams=["front","persp","side","top"]
if each_cam_tr not in exclude_mayacams:
mc.setAttr(each_cam_tr+".tx", l=True)
The last part returns a RuntimeError: setAttr: No object matches name: f.tx
I don't understand where it's getting "f" from, and I'm tired of trying to figure it all out by myself. Someone please help me?
Solved! Go to Solution.